summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_request.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-05-28Merged with the default branch.Sergey Kandaurov1-0/+2
2021-05-24Fixed log action when using SSL certificates with variables.Maxim Dounin1-0/+2
When variables are used in ssl_certificate or ssl_certificate_key, a request is created in the certificate callback to evaluate the variables, and then freed. Freeing it, however, updates c->log->action to "closing request", resulting in confusing error messages like "client timed out ... while closing request" when a client times out during the SSL handshake. Fix is to restore c->log->action after calling ngx_http_free_request().
2021-03-24Cancel keepalive and lingering close on EOF better (ticket #2145).Sergey Kandaurov1-5/+5
Unlike in 75e908236701, which added the logic to ngx_http_finalize_request(), this change moves it to a more generic routine ngx_http_finalize_connection() to cover cases when a request is finalized with NGX_DONE. In particular, this fixes unwanted connection transition into the keepalive state after receiving EOF while discarding request body. With edge-triggered event methods that means the connection will last for extra seconds as set in the keepalive_timeout directive.
2021-03-30Merged with the default branch.Sergey Kandaurov1-5/+5
2021-02-17Merged with the default branch.Sergey Kandaurov1-14/+25
2021-02-11Reuse of connections in lingering close.Maxim Dounin1-1/+4
This is particularly important in HTTP/2, where keepalive connections are closed with lingering. Before the patch, reusing a keepalive HTTP/2 connection resulted in the connection waiting for lingering close to remain in the reusable connections queue, preventing ngx_drain_connections() from closing additional connections. The patch fixes it by marking the connection reusable again, and so moving it in the reusable connections queue. Further, it makes actually possible to reuse such connections if needed.
2021-01-19Core: removed post_accept_timeout.Maxim Dounin1-13/+21
Keeping post_accept_timeout in ngx_listening_t is no longer needed since we've switched to 1 second timeout for deferred accept in 5541:fdb67cfc957d. Further, using it in HTTP code can result in client_header_timeout being used from an incorrect server block, notably if address-specific virtual servers are used along with a wildcard listening socket, or if we've switched to a different server block based on SNI in SSL handshake.
2020-12-21HTTP/3: removed HTTP/3-specific code.Roman Arutyunyan1-7/+5
The ngx_http_set_lingering_close() function is not called for HTTP/3. The change reduces diff to the default branch.
2021-01-22HTTP/3: refactored request parser.Roman Arutyunyan1-162/+35
The change reduces diff to the default branch for src/http/ngx_http_request.c and src/http/ngx_http_parse.c.
2020-12-15Merged with the default branch.Sergey Kandaurov1-5/+7
2020-12-10Removed extra allocation for r->uri.Maxim Dounin1-1/+1
The ngx_http_parse_complex_uri() function cannot make URI longer and does not null-terminate URI, so there is no need to allocate an extra byte. This allocation appears to be a leftover from changes in 461:a88a3e4e158f (0.1.5), where null-termination of r->uri and many other strings was removed.
2020-12-10Fixed parsing of absolute URIs with empty path (ticket #2079).Maxim Dounin1-2/+6
When the request line contains request-target in the absolute-URI form, it can contain path-empty instead of a single slash (see RFC 7230, RFC 3986). Previously, the ngx_http_parse_request_line() function only accepted empty path when there was no query string. With this change, non-empty query is also correctly handled. That is, request line "GET http://example.com?foo HTTP/1.1" is accepted and results in $uri "/" and $args "foo". Note that $request_uri remains "?foo", similarly to how spaces in URIs are handled. Providing "/?foo", similarly to how "/" is provided for "GET http://example.com HTTP/1.1", requires allocation.
2020-12-08SSL: fixed SSL shutdown on lingering close.Ruslan Ermilov1-2/+0
Ensure c->recv is properly reset to ngx_recv if SSL_shutdown() blocks on writing. The bug had appeared in 554c6ae25ffc.
2020-11-25HTTP/3: eliminated r->method_start.Roman Arutyunyan1-2/+6
The field was introduced to ease parsing HTTP/3 requests. The change reduces diff to the default branch.
2020-11-24Merged with the default branch.Sergey Kandaurov1-15/+31
2020-11-10QUIC: renamed c->qs to c->quic.Roman Arutyunyan1-4/+4
2020-11-06SSL: fixed non-working SSL shutdown on lingering close.Ruslan Ermilov1-8/+31
When doing lingering close, the socket was first shut down for writing, so SSL shutdown initiated after lingering close was not able to send the close_notify alerts (ticket #2056). The fix is to call ngx_ssl_shutdown() before shutting down the socket.
2020-11-06Removed dead code from ngx_http_set_keepalive().Ruslan Ermilov1-7/+0
The code removed became dead after 98f03cd8d6cc (0.8.14), circa when the request reference counting was introduced.
2020-10-29Merged with the default branch.Sergey Kandaurov1-14/+27
2020-10-22SSL: ssl_reject_handshake directive (ticket #195).Maxim Dounin1-14/+27
In some cases it might be needed to reject SSL handshake based on SNI server name provided, for example, to make sure an invalid certificate is not returned to clients trying to contact a name-based virtual server without SSL configured. Previously, a "ssl_ciphers aNULL;" was used for this. This workaround, however, is not compatible with TLSv1.3, in particular, when using BoringSSL, where it is not possible to configure TLSv1.3 ciphers at all. With this change, the ssl_reject_handshake directive is introduced, which instructs nginx to reject SSL handshakes with an "unrecognized_name" alert in a particular server block. For example, to reject handshake with names other than example.com, one can use the following configuration: server { listen 443 ssl; ssl_reject_handshake on; } server { listen 443 ssl; server_name example.com; ssl_certificate example.com.crt; ssl_certificate_key example.com.key; } The following configuration can be used to reject all SSL handshakes without SNI server name provided: server { listen 443 ssl; ssl_reject_handshake on; } server { listen 443 ssl; server_name ~^; ssl_certificate example.crt; ssl_certificate_key example.key; } Additionally, the ssl_reject_handshake directive makes configuring certificates for the default server block optional. If no certificates are configured in the default server for a given listening socket, certificates must be defined in all non-default server blocks with the listening socket in question.
2020-10-01Merged with the default branch.Sergey Kandaurov1-1/+4
2020-10-01QUIC: moved ssl configuration pointer to quic configuration.Vladimir Homutov1-5/+1
The ssl configuration is obtained at config time and saved for future use.
2020-09-29QUIC: switch stream context to a server selected by SNI.Roman Arutyunyan1-2/+15
Previously the default server configuration context was used until the :authority or host header was parsed. This led to using the configuration parameters like client_header_buffer_size or request_pool_size from the default server rather than from the server selected by SNI. Also, the switch to the right server log is implemented. This issue manifested itself as QUIC stream being logged to the default server log until :authority or host is parsed.
2020-09-23QUIC: unbreak client certificate verification after 0d2b2664b41c.Sergey Kandaurov1-0/+2
Initially, client certificate verification didn't work due to the missing hc->ssl on a QUIC stream, which is started to be set in 7738:7f0981be07c4. Then it was lost in 7999:0d2b2664b41c introducing "quic" listen parameter. This change re-adds hc->ssl back for all QUIC connections, similar to SSL.
2020-09-24SSL: abort handshake on SSL_set_SSL_CTX() errors.Sergey Kandaurov1-1/+4
In rare cases, such as memory allocation failure, SSL_set_SSL_CTX() returns NULL, which could mean that a different SSL configuration has not been set. Note that this new behaviour seemingly originated in OpenSSL-1.1.0 release.
2020-08-25HTTP/3: drop the unwanted remainder of the request.Roman Arutyunyan1-0/+7
As per HTTP/3 draft 29, section 4.1: When the server does not need to receive the remainder of the request, it MAY abort reading the request stream, send a complete response, and cleanly close the sending part of the stream.
2020-08-18Merged with the default branch.Roman Arutyunyan1-0/+12
2020-08-10SSL: disabled sending shutdown after ngx_http_test_reading().Maxim Dounin1-0/+6
Sending shutdown when ngx_http_test_reading() detects the connection is closed can result in "SSL_shutdown() failed (SSL: ... bad write retry)" critical log messages if there are blocked writes. Fix is to avoid sending shutdown via the c->ssl->no_send_shutdown flag, similarly to how it is done in ngx_http_keepalive_handler() for kqueue when pending EOF is detected. Reported by Jan Prachaƙ (http://mailman.nginx.org/pipermail/nginx-devel/2018-December/011702.html).
2020-08-06Added size check to ngx_http_alloc_large_header_buffer().Maxim Dounin1-0/+6
This ensures that copying won't write more than the buffer size even if the buffer comes from hc->free and it is smaller than the large client header buffer size in the virtual host configuration. This might happen if size of large client header buffers is different in name-based virtual hosts, similarly to the problem with number of buffers fixed in 6926:e662cbf1b932.
2020-08-11QUIC: fixed ngx_http_test_reading() for QUIC streams.Roman Arutyunyan1-0/+13
Previously this function generated an error trying to figure out if client shut down the write end of the connection. The reason for this error was that a QUIC stream has no socket descriptor. However checking for eof is not the right thing to do for an HTTP/3 QUIC stream since HTTP/3 clients are expected to shut down the write end of the stream after sending the request. Now the function handles QUIC streams separately. It checks if c->read->error is set. The error flags for c->read and c->write are now set for all streams when closing the QUIC connection instead of setting the pending_eof flag.
2020-07-23HTTP/3: server pushes.Roman Arutyunyan1-2/+1
New directives are added: - http3_max_concurrent_pushes - http3_push - http3_push_preload
2020-07-14HTTP/3: support $server_protocol variable.Roman Arutyunyan1-4/+0
Now it holds "HTTP/3.0". Previously it was empty.
2020-07-22HTTP/3: do not call shutdown() for QUIC streams.Roman Arutyunyan1-5/+7
Previously, this triggered an alert "shutdown() failed" in error log.
2020-07-21QUIC: eliminated connection handler argument in ngx_quic_run().Roman Arutyunyan1-1/+1
Now c->listening->handler() is called instead.
2020-07-21QUIC: added "quic" listen parameter.Roman Arutyunyan1-107/+42
The parameter allows processing HTTP/0.9-2 over QUIC. Also, introduced ngx_http_quic_module and moved QUIC settings there
2020-06-30HTTP/3: set r->headers_in.chunked flag after parsing headers.Roman Arutyunyan1-1/+6
Previously it was set when creating the request object. The side-effect was trying to discard the request body in case of header parse error.
2020-07-02HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.Roman Arutyunyan1-5/+7
Previously errors led only to closing streams. To simplify closing QUIC connection from a QUIC stream context, new macro ngx_http_v3_finalize_connection() is introduced. It calls ngx_quic_finalize_connection() for the parent connection.
2020-07-02HTTP/3: refactored dynamic table implementation.Roman Arutyunyan1-2/+19
Previously dynamic table was not functional because of zero limit on its size set by default. Now the following changes enable it: - new directives to set SETTINGS_QPACK_MAX_TABLE_CAPACITY and SETTINGS_QPACK_BLOCKED_STREAMS - send settings with SETTINGS_QPACK_MAX_TABLE_CAPACITY and SETTINGS_QPACK_BLOCKED_STREAMS to the client - send Insert Count Increment to the client - send Header Acknowledgement to the client - evict old dynamic table entries on overflow - decode Required Insert Count from client - block stream if Required Insert Count is not reached
2020-06-02Decoupled validation of Host and :authority for HTTP/2 and HTTP/3.Roman Arutyunyan1-3/+11
Previously an error was triggered for HTTP/2 when host with port was passed by client.
2020-05-29Require ":authority" or "Host" in HTTP/3 and HTTP/2 requests.Roman Arutyunyan1-0/+25
Also, if both are present, require that they have the same value. These requirements are specified in HTTP/3 draft 28. Current implementation of HTTP/2 treats ":authority" and "Host" interchangeably. New checks only make sure at least one of these values is present in the request. A similar check existed earlier and was limited only to HTTP/1.1 in 38c0898b6df7.
2020-05-26Merged with the default branch.Sergey Kandaurov1-0/+12
2020-05-22SSL: client certificate validation with OCSP (ticket #1534).Roman Arutyunyan1-0/+12
OCSP validation for client certificates is enabled by the "ssl_ocsp" directive. OCSP responder can be optionally specified by "ssl_ocsp_responder". When session is reused, peer chain is not available for validation. If the verified chain contains certificates from the peer chain not available at the server, validation will fail.
2020-05-19Fixed client buffer reallocation for HTTP/3.Roman Arutyunyan1-29/+19
Preserving pointers within the client buffer is not needed for HTTP/3 because all data is either allocated from pool or static. Unlike with HTTP/1, data typically cannot be referenced directly within the client buffer. Trying to preserve NULLs or external pointers lead to broken pointers. Also, reverted changes in ngx_http_alloc_large_header_buffer() not relevant for HTTP/3 to minimize diff to mainstream.
2020-05-19Fixed $request_length for HTTP/3.Roman Arutyunyan1-13/+14
New field r->parse_start is introduced to substitute r->request_start and r->header_name_start for request length accounting. These fields only work for this purpose in HTTP/1 because HTTP/1 request line and header line start with these values. Also, error logging is now fixed to output the right part of the request.
2020-05-19HTTP/3: restricted symbols in header names.Roman Arutyunyan1-4/+6
As per HTTP/3 draft 27, a request or response containing uppercase header field names MUST be treated as malformed. Also, existing rules applied when parsing HTTP/1 header names are also applied to HTTP/3 header names: - null character is not allowed - underscore character may or may not be treated as invalid depending on the value of "underscores_in_headers" - all non-alphanumeric characters with the exception of '-' are treated as invalid Also, the r->locase_header field is now filled while parsing an HTTP/3 header. Error logging for invalid headers is fixed as well.
2020-05-19HTTP/3: split header parser in two functions.Roman Arutyunyan1-1/+1
The first one parses pseudo-headers and is analagous to the request line parser in HTTP/1. The second one parses regular headers and is analogous to the header parser in HTTP/1. Additionally, error handling of client passing malformed uri is now fixed.
2020-04-23Assign connection number to every QUIC stream log.Roman Arutyunyan1-1/+0
2020-04-14Merged with the default branch.Sergey Kandaurov1-23/+11
2020-03-27Parsing HTTP/3 request body.Roman Arutyunyan1-0/+1
2020-03-24Removed ngx_quic_stream_node_t.Roman Arutyunyan1-1/+1
Now ngx_quic_stream_t is directly inserted into the tree.