Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed setting headers

  • Loading branch information...
commit 8a709ebe52077a139034614a855d3bd4cb88e3fe 1 parent 46ca997
@substack authored
Showing with 5 additions and 4 deletions.
  1. +3 −3 index.js
  2. +2 −1  lib/split.js
View
6 index.js
@@ -38,14 +38,14 @@ function makeBounce (req, stream, client) {
if (!opts) opts = {};
if (!opts.headers) opts.headers = {};
- if (opts.headers['x-forwarded-for'] !== false) {
+ if (opts.headers['x-forwarded-for'] === undefined) {
opts.headers['x-forwarded-for'] = client.remoteAddress;
}
- if (opts.headers['x-forwarded-port'] !== false) {
+ if (opts.headers['x-forwarded-port'] === undefined) {
var m = (req.headers.host || '').match(/:(\d+)/);
opts.headers['x-forwarded-port'] = m && m[1] || 80;
}
- if (opts.headers['x-forwarded-proto'] !== false) {
+ if (opts.headers['x-forwarded-proto'] === undefined) {
opts.headers['x-forwarded-proto']
= client.encrypted ? 'https' : 'http';
}
View
3  lib/split.js
@@ -72,6 +72,7 @@ module.exports = function (stream, cb) {
onHeadersComplete(info);
var b = currentBuffer;
+ if (!b) return;
for (var i = offset; i < b.length - 3; i++) {
if (b[i+2] === slash.n && b[i+3] === slash.n) {
advance(b, i + 2, 2); // \n\n
@@ -100,7 +101,7 @@ module.exports = function (stream, cb) {
c.destroy();
}
else {
- if (!advanced && currentBuffer !== buf) {
+ if (!advanced && currentBuffer && currentBuffer !== buf) {
var b = currentBuffer.slice(offset, currentBuffer.length);
outgoing.write(b);
currentBuffer = buf;
Please sign in to comment.
Something went wrong with that request. Please try again.