From 227532779439062705991a86de5f335962ba9754 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 23 Jan 2022 19:28:07 +0900 Subject: [PATCH] nghttpx: Fix the issue that forwarded h3 GET request always has chunked TE --- .github/workflows/build.yml | 3 ++- README.rst | 3 ++- src/shrpx_http3_upstream.cc | 13 ++++++++----- src/shrpx_http3_upstream.h | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0eeb00f8..cdc73ca8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,8 +114,9 @@ jobs: - name: Build nghttp3 if: matrix.http3 == 'http3' run: | - git clone --depth 1 -b v0.1.1 https://github.com/ngtcp2/nghttp3 + git clone https://github.com/ngtcp2/nghttp3 cd nghttp3 + git checkout 207318c92e0578ac393c31dcd797e4a4dca3e31a autoreconf -i ./configure --prefix=$PWD/build --enable-lib-only make -j$(nproc) check diff --git a/README.rst b/README.rst index 679b9ded..2c9b5f0e 100644 --- a/README.rst +++ b/README.rst @@ -366,8 +366,9 @@ Build nghttp3: .. code-block:: text - $ git clone --depth 1 -b v0.1.1 https://github.com/ngtcp2/nghttp3 + $ git clone https://github.com/ngtcp2/nghttp3 $ cd nghttp3 + $ git checkout 207318c92e0578ac393c31dcd797e4a4dca3e31a $ autoreconf -i $ ./configure --prefix=$PWD/build --enable-lib-only $ make -j$(nproc) diff --git a/src/shrpx_http3_upstream.cc b/src/shrpx_http3_upstream.cc index 89ad3086..35718a81 100644 --- a/src/shrpx_http3_upstream.cc +++ b/src/shrpx_http3_upstream.cc @@ -1998,7 +1998,7 @@ int Http3Upstream::http_recv_request_header(Downstream *downstream, } namespace { -int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, +int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, int fin, void *user_data, void *stream_user_data) { auto upstream = static_cast(user_data); auto handler = upstream->get_client_handler(); @@ -2008,7 +2008,7 @@ int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, return 0; } - if (upstream->http_end_request_headers(downstream) != 0) { + if (upstream->http_end_request_headers(downstream, fin) != 0) { return NGHTTP3_ERR_CALLBACK_FAILURE; } @@ -2019,7 +2019,7 @@ int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, } } // namespace -int Http3Upstream::http_end_request_headers(Downstream *downstream) { +int Http3Upstream::http_end_request_headers(Downstream *downstream, int fin) { auto lgconf = log_config(); lgconf->update_tstamp(std::chrono::system_clock::now()); auto &req = downstream->request(); @@ -2115,8 +2115,11 @@ int Http3Upstream::http_end_request_headers(Downstream *downstream) { req.connect_proto = ConnectProto::WEBSOCKET; } - // We are not sure that request has body or not at the moment. - req.http2_expect_body = true; + if (!fin) { + req.http2_expect_body = true; + } else if (req.fs.content_length == -1) { + req.fs.content_length = 0; + } downstream->inspect_http2_request(); diff --git a/src/shrpx_http3_upstream.h b/src/shrpx_http3_upstream.h index 0e29356e..9e61bb74 100644 --- a/src/shrpx_http3_upstream.h +++ b/src/shrpx_http3_upstream.h @@ -125,7 +125,7 @@ public: int http_recv_request_header(Downstream *downstream, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags); - int http_end_request_headers(Downstream *downstream); + int http_end_request_headers(Downstream *downstream, int fin); int http_end_stream(Downstream *downstream); void start_downstream(Downstream *downstream); void initiate_downstream(Downstream *downstream);