aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.c
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2025-06-23 14:55:32 +0400
committerpluknet <pluknet@nginx.com>2025-06-23 20:12:21 +0400
commitcdf7a9c6cb7f344efc80d790fbacdc1c94ab16e3 (patch)
tree3542c37c2cf3f27b3a38c636bfb3bd4564477f50 /src/http/ngx_http_upstream.c
parent4eaecc5e8aa7bbaf9e58bf56560a8b1e67d0a8b7 (diff)
downloadnginx-cdf7a9c6cb7f344efc80d790fbacdc1c94ab16e3.tar.gz
nginx-cdf7a9c6cb7f344efc80d790fbacdc1c94ab16e3.zip
Upstream: fixed reinit request with gRPC and Early Hints.
The gRPC module context has connection specific state, which can be lost after request reinitialization when it comes to processing early hints. The fix is to do only a portion of u->reinit_request() implementation required after processing early hints, now inlined in modules. Now NGX_HTTP_UPSTREAM_EARLY_HINTS is returned from u->process_header() for early hints. When reading a cached response, this code is mapped to NGX_HTTP_UPSTREAM_INVALID_HEADER to indicate invalid header format.
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r--src/http/ngx_http_upstream.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index d1bcdbbe0..de0f92a4f 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1123,7 +1123,7 @@ ngx_http_upstream_cache_send(ngx_http_request_t *r, ngx_http_upstream_t *u)
return NGX_ERROR;
}
- if (rc == NGX_AGAIN) {
+ if (rc == NGX_AGAIN || rc == NGX_HTTP_UPSTREAM_EARLY_HINTS) {
rc = NGX_HTTP_UPSTREAM_INVALID_HEADER;
}
@@ -2533,9 +2533,7 @@ ngx_http_upstream_process_header(ngx_http_request_t *r, ngx_http_upstream_t *u)
continue;
}
- if (rc == NGX_OK
- && u->headers_in.status_n == NGX_HTTP_EARLY_HINTS)
- {
+ if (rc == NGX_HTTP_UPSTREAM_EARLY_HINTS) {
rc = ngx_http_upstream_process_early_hints(r, u);
if (rc == NGX_OK) {
@@ -2651,10 +2649,6 @@ ngx_http_upstream_process_early_hints(ngx_http_request_t *r,
}
}
- if (u->reinit_request(r) != NGX_OK) {
- return NGX_ERROR;
- }
-
ngx_http_clean_header(r);
ngx_memzero(&u->headers_in, sizeof(ngx_http_upstream_headers_in_t));