Closed alefwmm closed 4 years ago
I'm seeing the same issue (with both the latest version and v2.2.3+).
Here's a simple program to reproduce:
const http = require('http')
const https = require('https')
const HttpsProxyAgent = require('https-proxy-agent')
const server = http.createServer()
server.on('connect', (req, socket, head) => {
console.log('proxy got request for', req.url)
socket.end('HTTP/1.1 500 Internal Server Error\r\n\r\n')
})
server.listen(() => {
const opts = {
host: 'example.com',
agent: new HttpsProxyAgent('http://localhost:' + server.address().port)
}
https.get(opts, res => {
console.log('client got response:', res.statusCode)
res.resume()
res.on('end', () => {
console.log('client detected end of response')
})
})
})
If using the latest version res
will never emit an end
event. If using v2.2.2 it will.
Hello guys,
I have one problem currently and a possible solution for it. I am using
node-https-proxy-agent#3.0.1
withaxios#0.19.0
.It works properly when the proxy connects successfully. The problem comes when my proxy provider gives me an error response like
HTTP/1.1 502 Proxy Error
during the connection process. When this happens, I am unable to catch this response and then, a timeout is thrown by myaxios
instance.This is the case for all version beyond
node-https-proxy-agent#2.2.1
, the one that fixed a major security flaw. Readingaxios
code, I saw that it does not handle the closed socket properly, expecting the normal stream events to properly execute.This way, I chose to do the following:
Here a way to reproduce the problem:
Using the solution explained before, it worked. I would like to know if this is the best way to do this.
I am currently using this branch