From 053c7ac5889c280e1108b2bdd40c48d40920172a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 3 Sep 2019 00:29:01 +0900 Subject: [PATCH] nghttpx: Returns 408 if backend timed out before sending headers --- src/shrpx_http2_upstream.cc | 6 +++++- src/shrpx_https_upstream.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 7d48f563..c27fada3 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -1378,7 +1378,11 @@ int Http2Upstream::downstream_error(DownstreamConnection *dconn, int events) { } else { unsigned int status; if (events & Downstream::EVENT_TIMEOUT) { - status = 504; + if (downstream->get_request_header_sent()) { + status = 504; + } else { + status = 408; + } } else { status = 502; } diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 3a543acd..bfe4f7c2 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -893,7 +893,11 @@ int HttpsUpstream::downstream_error(DownstreamConnection *dconn, int events) { unsigned int status; if (events & Downstream::EVENT_TIMEOUT) { - status = 504; + if (downstream->get_request_header_sent()) { + status = 504; + } else { + status = 408; + } } else { status = 502; }