Proxying requests via the tunnel module as reccomended in the readme fail using got 10.
An error is thrown:
tunnel.js:208 var hostHeader = options.request.getHeader('host');
^
TypeError: options.request.getHeader is not a function at ...\node_modules\tunnel\lib\tunnel.js:208:38 at ClientRequest.onConnect (...\node_modules\tunnel\lib\tunnel.js:172:12)
I recognize that the error is thrown within tunnel code and not got, but as the README reccomends to use tunnel with example code provided, I think this behavior is worth opening an issue about.
No error is thrown, as occurs using got 9.6.0
Replace the proxy options with a working proxy (I have tested using both Charles proxy and live proxies)
const got = require('got');
const tunnel = require('tunnel');
got('https://sindresorhus.com', {
agent: tunnel.httpsOverHttp({
proxy: {
host: 'localhost',
port: "8888"
}
})
});
I have the same issue.
Temporary solution that I have created for myself
let https = require('https');
gotOptions.request = https.request;
gotOptions.hooks = {
beforeRequest: [
options => {
options.request.getHeader = (name) => options.headers[name] || null;;
}
]
};
Also have problems with this code
got('https://v4.icanhazip.com/', {
agent: tunnel.httpsOverHttp({ proxy: { ... }),
timeout: 5000
})
Error:
project/node_modules/tunnel/lib/tunnel.js:183
options.request.emit('error', error);
^
TypeError: options.request.emit is not a function
at ClientRequest.onError (/project/node_modules/tunnel/lib/tunnel.js:183:21)
at Object.onceWrapper (events.js:412:26)
at ClientRequest.emit (events.js:305:20)
at ClientRequest.EventEmitter.emit (domain.js:483:12)
at Socket.socketErrorListener (_http_client.js:423:9)
at Socket.emit (events.js:305:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at emitErrorNT (internal/streams/destroy.js:84:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Is there any ETA for the release of this fix?
test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...
this's the only work one
https://github.com/zjael/simple-proxy-agent
and much faster, about 3 times against before. (v9.x with tunnel)
@szmarczak
I noticed that when accessing https using above one with a Local Proxy
it doesn't work, just hang up, I think maybe its because got distinguish http/https strictly, but anyway, the protocol of 'Agent' is not so clear.
For comparison purposes, I tried needle, it works well.
plz make a test if you have time.
besides, when I try to GET this url
using same proxy node, same headers, the got trigger 503 error high probability. 90% maybe,(for both v9.x v10.x)
but needle works well almost every time, so wired.
are there some "internal marks" of Got, could be detected by the Oracle's anti-robo system?
test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...this's the only work one
https://github.com/zjael/simple-proxy-agent
https-proxy-agent works fine for me
test several packages,
tunnel, https-proxy-agent, proxy-agent and so on...
this's the only work one
https://github.com/zjael/simple-proxy-agenthttps-proxy-agent works fine for me
Not work for me as described above,
503 error,
but needle works well, so weird