Reason for Host Required in HTTP 1.1 GET

Last week, I started quite noisy in my Computer Networks class over the need for a mandatory Host offer in the HTTP 1.1 GET message header.

The reason I am provided, whether it is written on the Internet or screams to me by my classmates, is always the same: the need to support shared hosting . However, and I will try to be as clear as possible, this, apparently, does not make sense.

I understand that in order to allow two domains to be hosted on the same machine (and therefore share the same IP address), there must be a way to differentiate both domain names.

I don’t understand why it is impossible to achieve this without a Host (HTTP 1.0 style), using an absolute URL (e.g. GET http://www.example.org/index.html ) instead of a relative (e.g. GET /index.html ). When an HTTP message arrives at the server, it (the server) redirects the message to the appropriate host, not looking at the Host offer, but instead looking at the host name in the URL present in the message request line.

I would really appreciate it if one of you hardcore hackers could help me understand what exactly I am missing here.

+8
web networking network-protocols
source share
3 answers

This was discussed in this thread :

modest offers for HTTP / 2.0 with their justification.

  • Add a header to the client request, which indicates the host name and port of the URL that the client is accessing.

Rationale: one of the most requested features of a commercial server accompanying is the ability to run one server on one port and respond to it with different top-level pages depending on the hostname in the URL.

An absolute request URI is required (since there is no way for the client to know in advance whether the server is one or more sites):

Repeat the first sentence to include the host name somewhere. This would be the cleanest in the url itself: -

 GET http://hostname/fred http/2.0 

This is the syntax for redirecting proxies.

To whom was this argument:

Since there will be a client connection, some supporting host name reports and some not, it just doesn't matter how this information gets to the server. Since this does not matter, it is easier to implement the solution - this is the new HTTP protocol request header field. This allows all clients and servers to work, as they do now with no code changes. Clients and servers that really need a host name information can have small mods made to send an additional header field containing a URL and processing it.

[...]

All that I offer is that there is a better way to implement the delivery of information about the host name to the server, which does not include hacking the query syntax and can be backward compatible with all clients and servers.

Feel free to read to find out the final solution yourself. But be careful, it's easy to get lost there.

+5
source

The reason for the "Host" header is to indicate which host this request belongs to. Without a “host”, the server must know in advance that it must direct “ http://joesdogs.com/ 'to Joe Dogs, while it must route' http://joscats.com/ 'to Jo Cats, even if they are the same web server. (What if the server has 2 names, for example "joscats.com" and "joescats.com", which should link to the same site?)

Having an explicit "Host" header makes such solutions much easier to program.

0
source

The reason for adding support for specifying the host in the HTTP request was the limited supply of IP addresses (which was not a problem when HTTP 1.0 was released).

If in your question “why indicate the host in the host header and not on the query line”, then the answer is the need for interaction between HTTP / 1.0 and 1.1.

If the question is “why is the Host header necessary”, this is due to the desire to expedite the transition from the assigned IP addresses.

Here are some guidelines for maintaining Internet addresses with respect to HTTP / 1.1.

0
source

All Articles