mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] fixed that f..reaking bug
This commit is contained in:
parent
1a4da5d76e
commit
10c218b804
BIN
lib/node-http-proxy/.http-proxy.js.swp
Normal file
BIN
lib/node-http-proxy/.http-proxy.js.swp
Normal file
Binary file not shown.
@ -11,8 +11,6 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
|
||||
var self = this,
|
||||
target = options.target,
|
||||
source = options.source;
|
||||
|
||||
self.origRes = response;
|
||||
|
||||
this.once('pipe', function(req) {
|
||||
var protocol = target.https ? https : http,
|
||||
@ -25,10 +23,11 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
|
||||
}
|
||||
|
||||
self.request = protocol.request(outgoing);
|
||||
self.request.end();
|
||||
self.on('finish', function() {
|
||||
self.request.end();
|
||||
});
|
||||
|
||||
self.request.on('response', function (res) {
|
||||
console.log('yarr yarr');
|
||||
self.response = res;
|
||||
if(req.httpVersion === '1.0') {
|
||||
res.headers.connection = req.headers.connection || 'close';
|
||||
@ -62,6 +61,15 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
|
||||
response.setHeader(key, res.headers[key]);
|
||||
});
|
||||
response.writeHead(response.statusCode);
|
||||
|
||||
res.on('readable', function() {
|
||||
self.read(0);
|
||||
});
|
||||
|
||||
res.on('end', function() {
|
||||
self.push(null);
|
||||
});
|
||||
self.emit('readable');
|
||||
});
|
||||
|
||||
|
||||
@ -128,6 +136,6 @@ ProxyStream.prototype._write = function(chunk, encoding, callback) {
|
||||
|
||||
ProxyStream.prototype._read = function(size) {
|
||||
var chunk = this.response ? this.response.read(size) : '';
|
||||
console.log(chunk.toString());
|
||||
if(chunk == null) { chunk = '' }
|
||||
this.push(chunk);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user