apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.

Home Page:https://www.npmjs.com/package/proxy-chain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proxy-chain send one header with unique name

shershennm opened this issue · comments

If request have multiple headers with same name, proxy-chain will leave only one (last). Example:

const http = require('http');
const ProxyChain = require('proxy-chain');

const server = http.createServer((req, res) => { 
    res.writeHead(200, [['Set-Cookie', 'foo=bar; path=/; HttpOnly'], ['Set-Cookie', 'bar=foo; path=/; HttpOnly']]) 
    res.end();
}).listen(3000);

const proxyServer = (new ProxyChain.Server()).listen(8000);

Without proxy: curl 127.0.0.1:3000 -vvv

> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.55.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Set-Cookie: foo=bar; path=/; HttpOnly
< Set-Cookie: bar=foo; path=/; HttpOnly
< Date: Mon, 18 Dec 2017 09:18:05 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked

With proxy: curl -x 127.0.0.1:8000 127.0.0.1:3000 -vvv

> GET http://127.0.0.1:3000/ HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.55.1
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK
< Set-Cookie: bar=foo; path=/; HttpOnly
< Date: Mon, 18 Dec 2017 09:17:49 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked

Fixed and published. Thx @shershennm