How to know that an HTTP response is a response to HEAD request

httphttp-headers

Let's say I see an HTTP response with its header.

How do I know if it is a response to a HEAD request?

RFC 2616 states that if 200 OK is the status of the response, it should contain a message body only if it's not a response to a HEAD request. So I need to know if it is a response to a HEAD.

Do I have to keep a state and remember whether it is a response to a HEAD or is it possible to know that only from the response fields?

Thanks.

Best Answer

To allow you to see how the responses differ, you can use telnet:

> telnet myserver 80
> GET / HTTP/1.0

> telnet myserver 80
> HEAD / HTTP/1.0

...but as radius commented, you appear to have answered your own question; if you get code 200 in response, with no body, assume it's a response to a HEAD request.

Related Topic