Closed coret closed 1 month ago
The legacy n2t implementation would redirect POST, PUT, etc with a 302 by default, which can lead to ambiguity in client behavior. HTTP status codes 307 and 308 were introduced to reconcile the ambiguity and direct a client to reuse the same method on redirected target. From the perspective of a resolver service, the intent is to redirect a client to the known location of a resource, hence it would appear correct to perform redirect for any of HEAD, GET, POST, PUT, and DELETE, with the caveat that POST, PUT, and DELETE requests should use 307 or 308 to ensure the client uses the same method on the redirected request.
Task here is to add additional HTTP method handling to support methods other than GET and HEAD.
Behavior:
302 Found
, the resolver should respond with a 307 Temporary Redirect
if request method is any of POST, PUT, DELETE301 Moved Permanenty
, resolver should respond with 308 Permanent Redirect
for POST, PUT, or DELETEN2T and ARKs.org resolver has been updated to support redirection on HTTP POST, PUT, and DELETE methods (in addition to HEAD and GET). Deployed N2T tag v0.9.1 to stage and production environments.
When I POST data to https://n2t.net/ark:/60537/aCtXvNJ I get a HTTP 405 error with contents
{"detail":"Method Not Allowed"}
. This seem to be triggered by fastapi in nt2/app.pyI think redirecting (with HTTP 307 to keep method) of POST requests is allowed per spec. If so, please implement POST method in resolver. It's the client responsibility to repeat the POST of data (not the resolver).
For testing purposes:
I expected that a POST to https://n2t.net/ark:/60537/aCtXvNJ would have been redirected to https://www.goudatijdmachine.nl/ark:/60537/aCtXvNJ as the following does have the desired output: