Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

308 Permanent Redirect or 303 See Also #29

Open
evanp opened this issue Nov 16, 2024 · 3 comments
Open

308 Permanent Redirect or 303 See Also #29

evanp opened this issue Nov 16, 2024 · 3 comments

Comments

@evanp
Copy link
Collaborator

evanp commented Nov 16, 2024

I added the 308 code as the right way to do a redirect for content negotiation, but I wasn't able to find any documentation for it. 303 See Also is more usual for providing a different representation for a resource. Is there good documentation for the 308 instead?

@evanp
Copy link
Collaborator Author

evanp commented Nov 18, 2024

@julianlam I think you're the person who mentioned this technique. Do you have a reference for it?

@julianlam
Copy link

julianlam commented Nov 18, 2024

I think in general a 301 or 308 is adequate. I have not ever seen 303 in the wild (though that's interesting in and of itself!).

Either is fine, since the only difference is 308 is "newer" than the older 301, and mandates that the request method be preserved, which is not a requirement for 301.

Additionally, most request libraries likely already handle 301/308 transparently, so I'd recommend sticking to that pair.

@trwnh
Copy link

trwnh commented Mar 3, 2025

301/308 is a "permanent redirect" and is supposed to be taken as a signal to rewrite old urls. This is inappropriate for discovering a representation.

303 See Other is defined with semantics such that the Location is a resource that represents the response. For a URI that has multiple representations, you should be using one of the following:

  • 200 OK if the content negotiation succeeded
  • 303 See Other if the requested representation has a different URI from the current resource
  • 406 Not Acceptable if the requested representation cannot be provided.

(300 Multiple Choices is also possible if doing server-driven content negotiation, but generally you will be doing agent-driven content negotiation instead.)

So the example should look like this:

GET /foo HTTP/1.1
Host: mixed.example
Accept: application/activity+json
HTTP/1.1 303 See Other
Location: https://mixed.example/foo?as2

A 301/308 should be interpreted as "forget about https://mixed.example/foo and make all future requests to https://mixed.example/foo?as2 instead". This means all requests, even if you are requesting the HTML!

By contrast, a 303 should be interpreted as "you requested an AS2 representation of https://mixed.example/foo and there is a representation at https://mixed.example/foo?as2 that you should look at".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants