5

Possible Duplicate:
404 header - HTTP 1.0 or 1.1?

Should you use

header( "HTTP/1.0 404 Not Found", true, 404 );

instead of

header( "HTTP/1.1 404 Not Found", true, 404 );

when the user agent uses HTTP/1.0? That is, is it good to reply with the same HTTP version?

Btw, I'm using it to claim that a page doesn't exist to users currently not logged in. I understand that it is different versions and that HTTP/1.1 has different functions.

Community
  • 1
  • 1
bloodphp
  • 117
  • 1
  • 7
  • @Matt Ball I've read the answers at http://stackoverflow.com/questions/2769371/404-header-http-1-0-or-1-1 but I feel that they don't answer whether it is a good practice to reply with HTTP/1.1 if the client uses it. I mean, the next request could go faster if the web server replies with HTTP/1.1 due to connection limits in HTTP/1.0. – AndersTornkvist May 15 '11 at 20:15
  • @Matt Ball More correctly, the answers there actually recommend to always reply with HTTP/1.0. I agree that this could actually be a duplicate. – AndersTornkvist May 15 '11 at 20:18
  • @Matt I guess I got the same answer here, but my question was maybe not so clear. I thought of the benefits of using HTTP/1.1. Maybe the answers at http://stackoverflow.com/questions/2769371/404-header-http-1-0-or-1-1 could be improved, since no more answers are allowed here. – bloodphp May 15 '11 at 20:22
  • @Richard86 are there benefits of using HTTP/1.1 if the client uses it? – bloodphp May 15 '11 at 20:23
  • Read the current **HTTPbis** specification. http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#page-15 - HTTP/1.x versions are supposed to behave equally. It also lists some advise for dealing with different client versions. -- Btw, PHP and Apache filter your Status: line anyway. If in doubt, use `HTTP/1.0` and don't be bitten by semantic differences. – mario May 15 '11 at 20:23

2 Answers2

1

When the user agent says it uses HTTP 1.0 (specified in RFC 1945 dated May 1996) you should not assume that it understands a protocol that was developed later (like HTTP 1.1 specified in RFC 2616 dated June 1999). So use HTTP 1.0 in the reply.

Oswald
  • 31,254
  • 3
  • 43
  • 68
0

If you don't want to distinguish between 1.0 and 1.1 and want to send a static header, I guess

header( "HTTP/1.0 404 Not Found", true, 404 );

is the safe way to do it - every client speaks HTTP/1.0.

But I also expect that no client at all checks the http version in case of a 404. At least, I never experienced problems with the http version...

rdmueller
  • 10,742
  • 10
  • 69
  • 126
  • 1
    Does this mean the connection will no longer support HTTP 1.1 features like persistent connections? Sending HTTP 1.0 as a blanket rule seems lazy and unwise to me, especially for 404 pages that include CSS and other external assets. – ChaseMoskal Jun 23 '13 at 22:29