httpx icon indicating copy to clipboard operation
httpx copied to clipboard

httpx ignores manually set User-Agent header when multiple headers are provided and sets a random one

Open jimen0 opened this issue 3 years ago • 0 comments

httpx version:

Current dev HEAD.

commit 2654ffa1076c09f7edc8c1c5fa9f5f32ef83bdc7 (HEAD -> dev, origin/dev)

Current Behavior:

$ echo "https://example.com/hello" | ./httpx -H 'foo: bar' -H 'user-agent: curl/7.79.1' -debug-req

results in the following HTTP request being issued:

GET /hello HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55
Accept-Charset: utf-8
Foo: bar
Accept-Encoding: gzip

Expected Behavior:

GET /hello HTTP/1.1
Host: example.com
User-Agent: curl/7.79.1
Accept-Charset: utf-8
Foo: bar
Accept-Encoding: gzip

Should have been issued instead.

Steps To Reproduce:

$ echo "https://example.com/hello" | ./httpx -H 'foo: bar' -H 'user-agent: curl/7.79.1' -debug-req

Anything else:

I built httpx using gotip:

$ go version -m ./httpx
./httpx: devel go1.20-2eba2ff8a1 Fri Aug 26 03:34:25 2022 +0000

jimen0 avatar Aug 26 '22 10:08 jimen0