http-status-codeshttp-proxyvirus

HTTP status code for a resource infected by virus


I'm developing an application which acts as an Http-Proxy for serving files from an external resource. It actually downloads the file from the external resource, checks for viruses and if the file is not infected, returns the file to the client.

My problem is, in case of the file is infected, what HTTP Status code my service should return? I suppose that any type of 4xx error codes is not appropriate for that situation because this class of code is intended for Client errors.

Is a 502 (Bad Gateway) error more appropriate? Is there any kind of Standard that covers this situation?


Solution

  • I think you are right maestromarko : 502 Bad Gateway. Read the specifications here:

    The 502 (Bad Gateway) status code indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.

    Your proxy is acting as a Gateway and he received what it conciders is invalid as there are virus in it.

    It is not a 4xx class error, because whatever the client changes in the request, the result will still be an error.

    See also this decision diagram