I am testing using nginx/php5-fpm
, with the code
<?php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
// also tested: header("Status: 404 Not Found");
echo $_SERVER["SERVER_PROTOCOL"];
And force to use HTTP 1.0 with the curl
command.
curl -0 -v 'http://www.example.com/test.php'
> GET /test.php HTTP/1.0
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Sat, 27 Oct 2012 08:51:27 GMT
< Content-Type: text/html
< Connection: close
<
* Closing connection #0
HTTP/1.0
As you can see I am already requesting using HTTP 1.0
, but nginx reply me with HTTP 1.1
Bounty
@MaximDounin, @MichaelHampton already provided an answer to the spec, thanks. I am extending this question a little bit for the future reader:
Q. What are the advantage of responding HTTP 1.1 when a client request for HTTP 1.0? Shouldn't the approach taken by Google more reasonable, i.e. when client request 1.0, response with 1.0?
This is normal and expected behavior, according to RFC 2616:
RFC 2145 expands on this:
What this means in English is: If the client sends an HTTP/1.0 request, either an HTTP/1.0 response or HTTP/1.1 is acceptable, but HTTP/1.1 is preferred.
The reason this is done is so that one end may advertise the highest version of HTTP that it can support, so that the other end may choose to upgrade its protocol support (if possible). Both ends will then decide what protocol version they can both live with. This design also helps to deal with buggy implementations, as RFC 2145 stated.
It was also envisioned at the time that there may be further versions of the HTTP protocol, both minor and major versions, and the rules were meant to help ensure interoperability. Google's RFC-ignorant approach may break once HTTP/2.0 is finalized. (You know it in its draft form as SPDY.)
It's actually sending you an HTTP/1.0-compliant response. It will not use any features such as keepalive that require HTTP/1.1.
The reason for doing this is because it's a cheap way for the server to say:
(Note: If the server supported a fictional HTTP/1.8, it would respond with that.)
This saves you an additional request in some situations. If you need to GET 3 different URIs from a server, you could send the first one as HTTP/1.0, then move up to the highest version that both you and the server support for the subsequent requests.