nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
6.24k stars 543 forks source link

`ProxyAgent` will cause customized `host` to reset #3019

Closed 1zilc closed 7 months ago

1zilc commented 7 months ago

Bug Description

ProxyAgent causes headers.host to be forcibly reset in undici.request

Reproducible By

undici.request('http://127.0.0.1:8000', {
  headers: {
    host: 'test.com',
  },
  dispatcher: new ProxyAgent({
    uri: 'http://127.0.0.1:1087',
  }),
});

Expected Behavior

request.headers.host should be test.com instead of 127.0.0.1:8000

Logs & Screenshots

image

Environment

macOS 14.4.0 node v20.11.0 undici 6.10.2

Additional context

without proxy

undici.request('http://127.0.0.1:8000', {
  headers: {
    host: 'test.com',
  },
});
image
metcoder95 commented 7 months ago

Thanks for the report, would you like to submit a PR for it?

1zilc commented 7 months ago

I'd love to try and fix it.