Is it correct to return a 502 status code when it's my proxy that has an internal error?

StackOverflow https://stackoverflow.com/questions/5934051

  •  30-10-2019
  •  | 
  •  

I've written a small proxy, and I'm wondering if it's correct for me to return a 502 Bad Gateway error when the proxy server itself has an internal error. The RFC seem to say that this is something you only do if the server on the other end gives a bad response.

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.

I take this to mean that if for example the upstream server is setting a content-length header that is different from the response body length, we should set a 502 error i.e. when the response is invalid.

Am I misinterpreting the RFC?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top