taf2 / curb

Ruby bindings for libcurl
Other
1.29k stars 229 forks source link

Not possible to remove the Host header #414

Closed incubus closed 2 years ago

incubus commented 4 years ago

Hi!

Is there any way to remove the Host header from the request?

$ ruby -rsocket -e "trap('SIGINT') { exit }; Socket.tcp_server_loop(8080) { |s,_| puts s.readpartial(1024); puts; s.puts 'HTTP/1.1 200'; s.close }

> Curl.post('http://localhost:8080')
=> #<Curl::Easy http://localhost:8080>
POST / HTTP/1.1
Host: localhost:8080
Accept: */*
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
> Curl.post('http://localhost:8080') { _1.headers = { 'Content-Type' => '', 'Content-Length' => '', 'Accept' => '', 'Host' => '' } }
=> #<Curl::Easy http://localhost:8080>
POST / HTTP/1.1
Host:

With curl:

$ curl -d '' -H 'User-Agent:' -H 'Content-Type:' -H 'Accept:' -H 'Content-Length:' -H 'Host:' http://127.0.0.1:8080

POST / HTTP/1.1
taf2 commented 2 years ago

Thank you for reporting this fix is in master now