简体   繁体   中英

How to know if a server supports HTTP 1.0

I need to know if a server supports HTTP 1.0. I send this message through a TCP socket:

GET / HTTP/1.0
Host: www.example.com

The thing is that in sometimes I get a HTTP 1.0 response and other times HTTP 1.1 response. How should I interpret this responses?

Thanks!

I need to know if a server supports HTTP 1.0.

When you send the request GET / HTTP/1.0 you're telling the server that the HTTP version you as a client support is 1.0.

If a server is either designed for HTTP 1.0 or designed for HTTP 1.1 with backwards compability to 1.0 then the server should send a 1.0 response to a 1.0 request, not a 1.1 response since the response might not be supported by the client.

In the HTTP protocol, the client is expected to send the version with the request, before it has any idea about what the server is or does.

That means that your trial-and-error approach is probably the only way to tell.

In practice, HTTP/1.0 isn't really in use the vast majority of the time, and it's almost always appropriate to use HTTP/1.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM