HTTP question

OK, RESTafarians and HTTP experts, here’s a question. Is it kosher to send a Location: header back with an ordinary, say 200, response?

Scenario: the server knows better than the client what the client needs. ‘I realize you asked for http://foo.com/x, but instead I’m sending you http://foo.com/y — ready or not, here it comes..’
-m

3 Responses to “HTTP question”

  1. Phil Wilson http://philwilson.org/blog/

    I’m no expert, but doesn’t it depend on what the client asks for? e.g. charset, encoding, language, Accept field etc.

    I suppose that all other things being equal, the server could return a 300 – Multiple Choices. In this case, the server can use the Location: field to specify which one of the multiple choices it thinks the client should see.

    In fact, the exact wording for 300 in RFC 2616 is: “If the server has a preferred choice of representation, it SHOULD include the specific URI for that representation in the Location field; user agents MAY use the Location field value for automatic redirection.”

  2. Leigh Dodds http://www.ldodds.com/blog

    Surely that scenario is a 302 or better yet a 303?

  3. Mark Baker http://www.markbaker.ca

    It sounds like you want a redirect, perhaps 302/307 or 303.

    The meaning of a Location header in a 200 response is undefined.

    If you don’t want to redirect, you can use Content-Location on the response.