9

RFC 7230, Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing states in the appendix:

As a result, clients are encouraged not to send the Proxy-Connection header field in any requests.

Why is curl sending this header then, when using a proxy?

$ http_proxy=0.0.0.0:8080 curl -v http://google.com
...
> Accept: */*
> Referer:
> Proxy-Connection: Keep-Alive
>
...

I am using curl 7.71.1 on x86_64-pc-linux-gnu.


Addendum: It's another protocol, but HTTP/2 explicitly disallows Connection and related fields, as per RFC 7540 Section 8.1.2.2

2 Answers 2

28

What an awesome question! Thanks for asking.

This is one example of the things on the web where the specs and what we should do doesn't really match up with reality and what happens if we try to follow those written guidelines!

Back in 2016 we (in the curl project) actually removed the Proxy-Connection: Keep-Alive header from curl requests done to proxies for exactly that reason: it isn't necessary since the protocol implies keep-alive and the spec says so!

Then (after that change) we immediately got a stream of bug reports from people whose proxy connections broke down completely and persistent connections simply failed to work... and once we reverted that change everything went back to working again.

So maybe around the year 2026 things have changed enough so we can run that experiment again. Until then we keep this header in proxy requests so that all those crappy legacy proxies in use out there don't go bananas!

The world wild web is a crazy place.

1
  • 2
    Better late than never: Thanks so much for the insight and for taking the time to share it with us.
    – miku
    May 12, 2022 at 11:55
1

Just a note by way of workaround,

I found my proxy was forwarding the Proxy-Connection header and for some reason the web server was returning 403 if it saw the header. Managed to remove the header with:

curl -v -x proxyserver --proxy-header "Proxy-Connection:" http://example.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.