views:

15

answers:

2

The main difference between HTTP/1.0 and HTTP/1.1 is that HTTP/1.1 has a mandatory Host Header in it. (Source: HTTP Pocket Reference - o'reilly)

So, why is that wget, which uses HTTP/1.0 protocol has host header in it?

My Output of wget with netcat

GET / HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 127.0.0.1:10101
Connection: Keep-Alive

As it is clear that wget uses HTTP/1.0 protocol version. How can it has Host header in it. Or am i getting somewhere wrong with my understanding of HTTP protocol?

And even if HTTP/1.0 can has Host Header in its HTTP request, what can be the reason behind wget using HTTP/1.0 protocol while HTTP/1.1 can also be used in place of that?

+1  A: 

In HTTP/1.0, the Host header was optional. The difference is that HTTP/1.1 changed it from optional to mandatory.

In particular, if the GET line doesn't include the hostname (like in your example), you need to include it in the headers (because otherwise, "virtual" domains would not be possible if the server cannot determine which host your request was for).

Dean Harding
+1  A: 

The Host header was added as an "optional" addition to HTTP/1.0 very early on when it was realized this was the only way to allow one server to serve up pages for multiple domains. wget uses HTTP/1.0 with Host as the way to be compatible with the maximum number of sites, some of which don't respond to HTTP/1.1 even though they require Host.

Paul Tomblin
but Paul, The server will make every attempt to conform to the most compatible version of HTTP that the client is using. so even if wget uses 1.1 server will use the most compatible one. either it be 1.1 or 1.0, why will it not respond to the request?
Idlecool
If the server doesn't understand 1.1, it won't respond to a 1.1 request. I know the number of servers that don't do 1.1 is probably miniscule these days, but since wget doesn't require anything that 1.1 can provide that 1.0 doesn't, why would it choose to cut out any 1.0 servers?
Paul Tomblin

related questions