Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var Duplex = require('stream').Duplex, | ||
proxy = require('../../node-http-proxy'); | ||
http = require('http'), | ||
https = require('https'), | ||
url = require('url'), | ||
util = require('util'); | ||
|
||
var ProxyStream = module.exports = function ProxyStream(target, changeOrigin) { | ||
Duplex.call(this); | ||
|
||
var self = this; | ||
|
||
this.once('pipe', function(req) { | ||
var protocol = target.https ? https : http, | ||
outgoing = proxy._getBase(target); | ||
|
||
proxy._setupOutgoing(outgoing, target, req); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
if (changeOrigin) { | ||
outgoing.headers.host = target.host + ':' + target.port; | ||
} | ||
|
||
self.request = protocol.request(outgoing, function(res) { | ||
if(req.httpVersion === '1.0') { | ||
res.headers.connection = req.headers.connection || 'close'; | ||
} | ||
else if(!res.headers.connection) { | ||
res.headers.connection = req.headers.connection || 'keep-alive'; | ||
} | ||
|
||
if(req.httpVersion === '1.0' || (req.method === 'DELETE' && !req.headers['content-length'])) { | ||
delete response.headers['transfer-encoding']; | ||
} | ||
|
||
if(~[301,302].indexOf(res.statusCode) && typeof response.headers.location !== 'undefined') { | ||
location = url.parse(response.headers.location); | ||
} | ||
|
||
}); | ||
}); | ||
|
||
}; | ||
|
||
ForwardStream.prototype._write = function(chunk, encoding, callback) { | ||
this.request.write(chunk, encoding, callback); | ||
}; | ||
|
||
util.inherits(ForwardStream, Duplex); |
Seems that
_setupOutgoing()
is not working proper, from_getBase()
comes just an empty functionfunction () {}
so thats the value ofoutgoing
after this point, so when the request is made some lines below theoutgoing
var has nothing.