dvonlehman / express-request-proxy

Advanced streaming http request proxy middleware for Express with support for custom routes, caching, and response transforms.
96 stars 38 forks source link

On timeout, should send 504 rather than 408? #19

Closed bsyk closed 6 years ago

bsyk commented 7 years ago

As this middleware is used to proxy to another server, should the error code on timeout be 504 (Gateway Timeout) rather than 408 (Request Timeout)? https://github.com/4front/express-request-proxy/blob/master/lib/proxy.js#L265

The issue here is that the HTTP specification for 408 allows clients to repeat the request. It seems that modern browsers (i.e. Chrome) will retry a few times before providing the error code to the client application. https://tools.ietf.org/html/rfc2068#section-10.4.9 vs https://tools.ietf.org/html/rfc2068#section-10.5.5

What do you think?

talawahtech commented 7 years ago

I second this. Gateway timeout is more accurate and Chrome's auto-retry behavior causes my app to spam the upstream API.

bsyk commented 6 years ago

Fixed in #36