summaryrefslogtreecommitdiffhomepage
path: root/src/http/v2
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2025-11-05 16:15:12 +0400
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>2025-11-26 19:51:40 +0400
commit6446f99107fff83469145b16983ebec99261a2db (patch)
tree0936fa0668aeab030baa8018e0314c4d05fad79b /src/http/v2
parent511abb19e1e1b127f6d0943ccac346211a490a35 (diff)
downloadnginx-6446f99107fff83469145b16983ebec99261a2db.tar.gz
nginx-6446f99107fff83469145b16983ebec99261a2db.tar.bz2
Changed interface of ngx_http_validate_host().
This allows to process a port subcomponent and save it in r->port in a unified way, similar to r->headers_in.server. For HTTP/1.x request line in the absolute form, r->host_end now includes a port subcomponent, which is also consistent with HTTP/2 and HTTP/3.
Diffstat (limited to 'src/http/v2')
-rw-r--r--src/http/v2/ngx_http_v2.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
index 4bfee589a..49ea25ede 100644
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -3518,8 +3518,8 @@ ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
static ngx_int_t
ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_str_t *value)
{
- u_char *p;
- ngx_int_t rc;
+ ngx_int_t rc;
+ in_port_t port;
if (r->host_start) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
@@ -3530,7 +3530,7 @@ ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_str_t *value)
r->host_start = value->data;
r->host_end = value->data + value->len;
- rc = ngx_http_validate_host(value, r->pool, 0);
+ rc = ngx_http_validate_host(value, &port, r->pool, 0);
if (rc == NGX_DECLINED) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
@@ -3552,16 +3552,7 @@ ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_str_t *value)
}
r->headers_in.server = *value;
-
- p = ngx_strlchr(r->host_start + value->len, r->host_end, ':');
-
- if (p) {
- rc = ngx_atoi(p + 1, r->host_end - p - 1);
-
- if (rc > 0 && rc < 65536) {
- r->port = rc;
- }
- }
+ r->port = port;
return NGX_OK;
}