I'm trying to determine what a client should do with headers on receiving a 303 (See Other) from the server. Specifically, what should be done with the Authorization
header that was sent on the initial request?
Here's the problem: the client makes a request to myserver.com
(HTTP request method is not relevant here) and the server at myserver.com
responds with a 303 and the Location
header contains otherserver.com/some_resource/
. Tools like Postman and curl will follow the redirect by passing all the same headers in the subsequent request to otherserver.com
. I haven't found a way to make these tools drop the headers.
In the case I've described, sending the Authorization
header to otherserver.com
seems like a security risk: otherserver.com
now knows my token and possibly what host it can be used on so now the token is compromised. This can also cause errors, depending on how the destination host is configured. In the case where the redirect is to another resources on the same host (ie, myserver.com
) then the Authorization
header will (probably) need to be sent, and because it's the same host nothing is compromised.
Effectively, in different situations it seems that the correct behaviour is different. The relevant section in the RFC does not address this issue. In developing my own API, I've written documentation telling API clients to drop the Authorization
header on redirect to otherserver.com
. However, based on mucking around with curl and Postman, it's not clear to me either (a) what the default behaviour is for a typical HTTP client library or (b) whether HTTP client libraries permit easy modification of the HTTP headers before following a 303 redirect. As a result, it's possible my suggestion isn't practical. I also know of no way for the server to instruct the client as to what it should do with headers on following the 303 redirect.
What should a HTTP client do with the headers when it follows a 303 redirect? Who is responsible for deciding whether to use the same headers on the redirect, the HTTP client or server?