Why do HTTP proxies require an absolute URI in their GET requests?
I noticed in the HTTP spec (section 5.1.2) that a HTTP request to a HTTP proxy uses an absolute URI:
GET http://stackoverflow.com/questions/1968887/uribuilder-and-in-uri HTTP/1.1
while 开发者_JS百科a non-proxied request uses a relative URI:
GET /relative_path.html HTTP/1.1
In either case, a "Host:" header is also specified. Since the "Host:" header already specifies the target of the request, why is the absolute URI required for the HTTP proxy? The spec says something about avoiding request loops, but I'm not at all certain that has anything to do with my question.
I've checked in a network monitor and verified that at least on my system, requests do behave as described above.
I suspect because the "Host" header only appeared in HTTP 1.1 (I think). Prior to that, the path was all there was. This wasn't enough for the proxy, so the host had to be added to the body for it to work.
It's sort-of redundant with HTTP 1.1, I suppose, but it's there for backward compatibility now.
精彩评论