Proper HTTP response code depending on remote server response
Kitodo.Presention can resolve URLs to get a METS document from some place on the web. However, the requested server might respond with an error code like 404 Not found or 403 Forbidden. In such cases Kitodo.Presntation should return the appropriate error code and an error page instead of 200 OK with empty page.
Which status code would you expect? I am thinking of 502 - Bad Gateway or maybe 504 - Gateway Timeout.
Not sure. These codes seem so have very particular focus.
502 Bad Gateway: "The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request." -> Maybe Kitodo.Presentation is not a proxy because it's not only passing along data.
504 Gateway Timeout: "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request." -> This could happen. But only then Kitodo.Presentation should return 504.
Another option could be to just pass along the error code returned by the METS resource.
Kitodo.Presentation doesn't act as a proxy, but it is a gateway since it fetches and processes remote resources in order to provide access to those resources. Don't you think?
I believe the error code should reflect the status of the service processing the user's request. So if an upstream resource is not available (status 404), this doesn't mean that Kitodo.Presentation itself is "not found". Simply passing along the upstream server's status code would therefore result in misleading error messages.
That is indeed true. Also if the given URL is rubbish the response code could be 400 Bad Request.