Last week I started quite a fuss in my Computer Networks class over the need for a mandatory Host
clause in the header of HTTP 1.1 GET messages.
The reason I'm provided with, be it written on the Web or shouted at me by my classmates, is always the same: the need to support virtual hosting. However, and I'll try to be as clear as possible, this does not appear to make sense.
I understand that in order to allow two domains to be hosted in a single machine (and by consequence, share the same IP address), there has to exist a way of differentiating both domain names.
What I don't understand is why it isn't possible to achieve this without a Host
clause (HTTP 1.0 style) by using an absolute URL (e.g. GET http://www.example.org/index.html
) instead of a relative one (e.g. GET /index.html
).
When the HTTP message got to the server, it (the server) would redirect the message to the appropriate host, not by looking at the Host
clause but, instead, by looking at the hostname in the URL present in the message's request line.
I would be very grateful if any of you hardcore hackers could help me understand what exactly am I missing here.
This was discussed in this thread:
modest suggestions for HTTP/2.0 with their rationale.
- Add a header to the client request that indicates the hostname and port of the URL which the client is accessing.
Rationale: One of the most requested features from commercial server maintainers is the ability to run a single server on a single port and have it respond with different top level pages depending on the hostname in the URL.
Making an absolute request URI required (because there's no way for the client to know on beforehand whether the server homes one or more sites) was suggested:
Re the first proposal, to incorporate the hostname somewhere. This would be cleanest put into the URL itself :-
GET http://hostname/fred http/2.0
This is the syntax for proxy redirects.
To which this argument was made:
Since there will be a mix of clients, some supporting host name reporting and some not, it just doesn't matter how this info gets to the server. Since it doesn't matter, the easier to implement solution is a new HTTP request header field. It allows all clients and servers to operate as they do now with NO code changes. Clients and servers that actually need host name information can have tiny mods made to send the extra header field containing the URL and process it.
[...]
All I'm suggesting is that there is a better way to implement the delivery of host name info to the server that doesn't involve hacking the request syntax and can be backwards compatible with ALL clients and servers.
Feel free to read on to discover the final decision yourself. But be warned, it's easy to get lost in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With