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; }