apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.
https://www.npmjs.com/package/proxy-chain
Apache License 2.0
804 stars 138 forks source link

Use key/value object in place of Array for requests headers #528

Closed Elyahou closed 5 months ago

Elyahou commented 5 months ago

I came across an issue where the anonymizeProxy helper function was not working correctly, and upstream proxy was returning 407, even if the username/password was correctly set in the proxy url.

I found out that the upstream proxy was not receiving the credential header correctly. http and https request should contain header according to the API.

With the proposed changes, the anonymizeProxy works correctly, and I no longer have errors

Elyahou commented 5 months ago

yes, so it seems that original implementation with array is to allow repeating headers, and my change break this.

Elyahou commented 5 months ago

It seems http support sending an array of value to support repeating headers, so I changed the forward function accordingly, now the tests pass

jancurn commented 5 months ago

So it worked fine with the array too, instead of object? The reason why we use array of raw headers is to preserve all even duplicate headers to make the proxy transparent.