HTTP HEAD and GET different result
Asked Answered
C

1

4

Should the HEAD and GET methods return the same status code? More specifically, we have run into the situation where a client website is returning a 200 when we do a HEAD, but returns a 303 when we do a GET. It has to do with redirecting to a language specific page based on location, but shouldn't the HEAD then also ask you to redirect?

Consumption answered 18/3, 2013 at 13:14 Comment(1)
That really depends on how the redirect is set up. If the redirect is set up to only respond to GET requests, then a HEAD request won't redirect.Ailanthus
W
5

but shouldn't the HEAD then also ask you to redirect?

The key is the word SHOULD. From the HTTP method specification, RFC9110:

9.3.2 HEAD

The HEAD method is identical to GET except that the server MUST NOT send content in the response. HEAD is used to obtain metadata about the selected representation without transferring its representation data, often for the sake of testing hypertext links or finding recent modifications.

The server SHOULD send the same header fields in response to a HEAD request as it would have sent if the request method had been GET. However, a server MAY omit header fields for which a value is determined only while generating the content..

The word SHOULD is further definied in RFC2119:

SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

So, the case you described is legit, but not recommended. You may want to ask the site maintainer for the reasoning of this path.

Wisconsin answered 18/3, 2013 at 13:20 Comment(2)
Thanks, that's what I thought. I SHOULD ask them for their reasoning ;-)Consumption
@Wisconsin This is what a precise answer looks like. +1.Lubric

© 2022 - 2024 — McMap. All rights reserved.