diff options
| author | Sergey Kandaurov <pluknet@nginx.com> | 2025-11-05 16:15:12 +0400 |
|---|---|---|
| committer | Roman Arutyunyan <arutyunyan.roman@gmail.com> | 2025-11-26 19:51:40 +0400 |
| commit | 6446f99107fff83469145b16983ebec99261a2db (patch) | |
| tree | 0936fa0668aeab030baa8018e0314c4d05fad79b /src/http/ngx_http_parse.c | |
| parent | 511abb19e1e1b127f6d0943ccac346211a490a35 (diff) | |
| download | nginx-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/ngx_http_parse.c')
| -rw-r--r-- | src/http/ngx_http_parse.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index 4dfeb4bcf..059edae44 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -383,21 +383,18 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) case sw_host_end: + if (ch == ':') { + state = sw_port; + break; + } + r->host_end = p; if (r->method == NGX_HTTP_CONNECT) { - if (ch == ':') { - state = sw_port; - break; - } - return NGX_HTTP_PARSE_INVALID_REQUEST; } switch (ch) { - case ':': - state = sw_port; - break; case '/': r->uri_start = p; state = sw_after_slash_in_uri; @@ -465,14 +462,11 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) case sw_port: if (ch >= '0' && ch <= '9') { - if (r->port >= 6553 && (r->port > 6553 || (ch - '0') > 5)) { - return NGX_HTTP_PARSE_INVALID_REQUEST; - } - - r->port = r->port * 10 + (ch - '0'); break; } + r->host_end = p; + if (r->method == NGX_HTTP_CONNECT) { if (ch == ' ') { state = sw_http_09; |
