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?

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.
    – rbedger
    Mar 18, 2013 at 13:21

1 Answer 1

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.

2
  • 1
    Thanks, that's what I thought. I SHOULD ask them for their reasoning ;-) Mar 18, 2013 at 13:33
  • @BalusC This is what a precise answer looks like. +1. Dec 15, 2015 at 12:46

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.