aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
Commit message (Collapse)AuthorAge
...
* Fixed CPU hog while freeing hc->busy after e662cbf1b932 (1.11.11).Maxim Dounin2017-03-24
| | | | | Reported by Richard Stanway, http://mailman.nginx.org/pipermail/nginx/2017-March/053296.html.
* Converted hc->busy/hc->free to use chain links.Maxim Dounin2017-03-07
| | | | | | | | Most notably, this fixes possible buffer overflows if number of large client header buffers in a virtual server is different from the one in the default server. Reported by Daniil Bondarev.
* SSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).Maxim Dounin2017-02-02
| | | | | | | | | | Previously, buffer size was not changed from the one saved during initial ngx_ssl_create_connection(), even if the buffer itself was not yet created. Fix is to change c->ssl->buffer_size in the SNI callback. Note that it should be also possible to update buffer size even in non-SNI virtual hosts as long as the buffer is not yet allocated. This looks like an overcomplication though.
* Fixed an error log message.Valentin Bartenev2016-06-07
|
* HTTP/2: the "421 Misdirected Request" response (closes #848).Valentin Bartenev2016-05-20
| | | | | | | | | | | | | | | | | | | | | | | | Since 4fbef397c753 nginx rejects with the 400 error any attempts of requesting different host over the same connection, if the relevant virtual server requires verification of a client certificate. While requesting hosts other than negotiated isn't something legal in HTTP/1.x, the HTTP/2 specification explicitly permits such requests for connection reuse and has introduced a special response code 421. According to RFC 7540 Section 9.1.2 this code can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. And the client may retry the request over a different connection. Now this code is used for requests that aren't authorized in current connection. After receiving the 421 response a client will be able to open a new connection, provide the required certificate and retry the request. Unfortunately, not all clients currently are able to handle it well. Notably Chrome just shows an error, while at least the latest version of Firefox retries the request over a new connection.
* Dav: return 501 on PUT with ranges (ticket #948).Maxim Dounin2016-05-16
|
* Improved EPOLLRDHUP handling.Valentin Bartenev2016-05-13
| | | | | | | | | | | | | | | | | When it's known that the kernel supports EPOLLRDHUP, there is no need in additional recv() call to get EOF or error when the flag is absent in the event generated by the kernel. A special runtime test is done at startup to detect if EPOLLRDHUP is actually supported by the kernel because epoll_ctl() silently ignores unknown flags. With this knowledge it's now possible to drop the "ready" flag for partial read. Previously, the "ready" flag was kept until the recv() returned EOF or error. In particular, this change allows the lingering close heuristics (which relies on the "ready" flag state) to actually work on Linux, and not wait for more data in most cases. The "available" flag is now used in the read event with the semantics similar to the corresponding counter in kqueue.
* Fixed logging.Sergey Kandaurov2016-03-31
|
* HTTP/2: implemented per request timeouts (closes #626).Valentin Bartenev2016-02-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there were only three timeouts used globally for the whole HTTP/2 connection: 1. Idle timeout for inactivity when there are no streams in processing (the "http2_idle_timeout" directive); 2. Receive timeout for incomplete frames when there are no streams in processing (the "http2_recv_timeout" directive); 3. Send timeout when there are frames waiting in the output queue (the "send_timeout" directive on a server level). Reaching one of these timeouts leads to HTTP/2 connection close. This left a number of scenarios when a connection can get stuck without any processing and timeouts: 1. A client has sent the headers block partially so nginx starts processing a new stream but cannot continue without the rest of HEADERS and/or CONTINUATION frames; 2. When nginx waits for the request body; 3. All streams are stuck on exhausted connection or stream windows. The first idea that was rejected was to detect when the whole connection gets stuck because of these situations and set the global receive timeout. The disadvantage of such approach would be inconsistent behaviour in some typical use cases. For example, if a user never replies to the browser's question about where to save the downloaded file, the stream will be eventually closed by a timeout. On the other hand, this will not happen if there's some activity in other concurrent streams. Now almost all the request timeouts work like in HTTP/1.x connections, so the "client_header_timeout", "client_body_timeout", and "send_timeout" are respected. These timeouts close the request. The global timeouts work as before. Previously, the c->write->delayed flag was abused to avoid setting timeouts on stream events. Now, the "active" and "ready" flags are manipulated instead to control the processing of individual streams.
* Fixed buffer over-read while logging invalid request headers.Valentin Bartenev2016-02-24
| | | | | | | | | | Since 667aaf61a778 (1.1.17) the ngx_http_parse_header_line() function can return NGX_HTTP_PARSE_INVALID_HEADER when a header contains NUL character. In this case the r->header_end pointer isn't properly initialized, but the log message in ngx_http_process_request_headers() hasn't been adjusted. It used the pointer in size calculation, which might result in up to 2k buffer over-read. Found with afl-fuzz.
* SSL: fixed possible segfault on renegotiation (ticket #845).Sergey Kandaurov2015-12-08
| | | | | | | | Skip SSL_CTX_set_tlsext_servername_callback in case of renegotiation. Do nothing in SNI callback as in this case it will be supplied with request in c->data which isn't expected and doesn't work this way. This was broken by b40af2fd1c16 (1.9.6) with OpenSSL master branch and LibreSSL.
* Style: unified request method checks.Ruslan Ermilov2015-11-06
|
* SSL: only select HTTP/2 using NPN if "http2" is enabled.Valentin Bartenev2015-11-05
| | | | | | OpenSSL doesn't check if the negotiated protocol has been announced. As a result, the client might force using HTTP/2 even if it wasn't enabled in configuration.
* The HTTP/2 implementation (RFC 7240, 7241).Valentin Bartenev2015-09-11
| | | | The SPDY support is removed, as it's incompatible with the new module.
* Limit recursive subrequests instead of simultaneous.Valentin Bartenev2015-08-23
|
* Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.Roman Arutyunyan2015-06-16
| | | | The new name is consistent with the ngx_proxy_protocol_write function.
* Core: the ngx_set_connection_log() macro.Vladimir Homutov2015-04-25
| | | | The http and stream versions of this macro were identical.
* Removed the obsolete rtsig module.Ruslan Ermilov2015-04-23
|
* Removed the obsolete aio module.Ruslan Ermilov2015-04-22
|
* Request body: unbuffered reading.Maxim Dounin2015-03-23
| | | | | | | | | | | The r->request_body_no_buffering flag was introduced. It instructs client request body reading code to avoid reading the whole body, and to call post_handler early instead. The caller should use the ngx_http_read_unbuffered_request_body() function to read remaining parts of the body. Upstream module is now able to use this mode, if configured with the proxy_request_buffering directive.
* SSL: reset ready flag if recv(MSG_PEEK) found no bytes in socket.Roman Arutyunyan2015-03-02
| | | | | | | | | | | Previously, connection hung after calling ngx_http_ssl_handshake() with rev->ready set and no bytes in socket to read. It's possible in at least the following cases: - when processing a connection with expired TCP_DEFER_ACCEPT on Linux - after parsing PROXY protocol header if it arrived in a separate TCP packet Thanks to James Hamlin.
* Upstream: improved subrequest logging.Maxim Dounin2014-12-02
| | | | | | | To ensure proper logging make sure to set current_request in all event handlers, including resolve, ssl handshake, cache lock wait timer and aio read handlers. A macro ngx_http_set_log_request() introduced to simplify this.
* Fixed possible buffer overrun in "too long header line" logging.Maxim Dounin2014-10-08
| | | | | | | Additionally, ellipsis now always added to make it clear that the header logged is incomplete. Reported by Daniil Bondarev.
* SPDY: avoid setting timeout on stream events in ngx_http_writer().Valentin Bartenev2014-08-27
| | | | | | | The SPDY module doesn't expect timers can be set on stream events for reasons other than delaying output. But ngx_http_writer() could add timer on write event if the delayed flag wasn't set and nginx is waiting for AIO completion. That could cause delays in sending response over SPDY when file AIO was used.
* Reset of r->uri.len on URI parsing errors.Maxim Dounin2014-07-18
| | | | | | | | This ensures that debug logging and the $uri variable (if used in 400 Bad Request processing) will not try to access uninitialized memory. Found by Sergey Bobrov.
* Added server-side support for PROXY protocol v1 (ticket #355).Roman Arutyunyan2014-03-17
| | | | | | | | Client address specified in the PROXY protocol header is now saved in the $proxy_protocol_addr variable and can be used in the realip module. This is currently not implemented for mail.
* Use ngx_socket_errno where appropriate.Piotr Sikora2014-02-03
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Fixed false compiler warning.Vladimir Homutov2014-01-31
| | | | | Newer gcc versions (4.7+) report possible use of uninitialized variable if nginx is being compiled with -O3.
* Fixed a compile warning introduced by 01e2a5bcdd8f.Ruslan Ermilov2014-01-30
| | | | | | On systems with OpenSSL that has NPN support but lacks ALPN support, some compilers emitted a warning about possibly uninitialized "data" variable.
* SSL: support ALPN (IETF's successor to NPN).Piotr Sikora2014-01-28
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Fixed TCP_DEFER_ACCEPT handling (ticket #353).Maxim Dounin2014-01-28
| | | | | | | | | | | | | | | | | Backed out 05a56ebb084a, as it turns out that kernel can return connections without any delay if syncookies are used. This basically means we can't assume anything about connections returned with deferred accept set. To solve original problem the 05a56ebb084a tried to solve, i.e. to don't wait longer than needed if a connection was accepted after deferred accept timeout, this patch changes a timeout set with setsockopt(TCP_DEFER_ACCEPT) to 1 second, unconditionally. This is believed to be enough for speed improvements, and doesn't imply major changes to timeouts used. Note that before 2.6.32 connections were dropped after a timeout. Though it is believed that 1s is still appropriate for kernels before 2.6.32, as previously tcp_synack_retries controlled the actual timeout and 1s results in more than 1 minute actual timeout by default.
* Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).Valentin Bartenev2013-09-16
| | | | | This allows to detect client connection close with pending data when the ngx_http_test_reading() request event handler is set.
* Request cleanup code unified, no functional changes.Maxim Dounin2013-09-04
| | | | | Additionally, detaching a cleanup chain from a request is a bit more resilent to various bugs if any.
* Assume the HTTP/1.0 version by default.Valentin Bartenev2013-09-02
| | | | | | | | | | | It is believed to be better than fallback to HTTP/0.9, because most of the clients at present time support HTTP/1.0. It allows nginx to return error response code for them in cases when it fail to parse request line, and therefore fail to detect client protocol version. Even if the client does not support HTTP/1.0, this assumption should not cause any harm, since from the HTTP/0.9 point of view it still a valid response.
* Fixed ngx_http_test_reading() to finalize request properly.Maxim Dounin2013-06-14
| | | | | | | Previous code called ngx_http_finalize_request() with rc = 0. This is ok if a response status was already set, but resulted in "000" being logged if it wasn't. In particular this happened with limit_req if a connection was prematurely closed during limit_req delay.
* Fixed lingering_time check.Maxim Dounin2013-05-13
| | | | | | | | | | | | | There are two significant changes in this patch: 1) The <= 0 comparison is done with a signed type. This fixes the case of ngx_time() being larger than r->lingering_time. 2) Calculation of r->lingering_time - ngx_time() is now always done in the ngx_msec_t type. This ensures the calculation is correct even if time_t is unsigned and differs in size from ngx_msec_t. Thanks to Lanshun Zhou.
* Fixed build with --with-mail_ssl_module.Maxim Dounin2013-05-11
| | | | | | | | | If nginx was compiled without --with-http_ssl_module, but with some other module which uses OpenSSL (e.g. --with-mail_ssl_module), insufficient preprocessor check resulted in build failure. The problem was introduced by e0a3714a36f8 (1.3.14). Reported by Roman Arutyunyan.
* Preliminary experimental support for SPDY draft 2.Valentin Bartenev2013-03-20
|
* URI processing code moved to a separate function.Valentin Bartenev2013-03-20
| | | | This allows to reuse it in the upcoming SPDY module.
* Allow to reuse connections that wait their first request.Valentin Bartenev2013-03-15
| | | | | | | | This should improve behavior under deficiency of connections. Since SSL handshake usually takes significant amount of time, we exclude connections from reusable queue during this period to avoid premature flush of them.
* Fixed logging in ngx_http_wait_request_handler().Maxim Dounin2013-03-12
| | | | | | | | If c->recv() returns 0 there is no sense in using ngx_socket_errno for logging, its value meaningless. (The code in question was copied from ngx_http_keepalive_handler(), but ngx_socket_errno makes sense there as it's used as a part of ECONNRESET handling, and the c->recv() call is preceeded by the ngx_set_socket_errno(0) call.)
* Refactored ngx_http_init_request().Valentin Bartenev2013-03-07
| | | | | Now it can be used as the request object factory with minimal impact on the connection object. Therefore it was renamed to ngx_http_create_request().
* Removed c->single_connection flag.Valentin Bartenev2013-03-07
| | | | | | | The c->single_connection was intended to be used as lock mechanism to serialize modifications of request object from several threads working with client and upstream connections. The flag is redundant since threads in nginx have never been used that way.
* Respect the new behavior of TCP_DEFER_ACCEPT.Valentin Bartenev2013-03-07
| | | | | | | | | In Linux 2.6.32, TCP_DEFER_ACCEPT was changed to accept connections after the deferring period is finished without any data available. (Reading from the socket returns EAGAIN in this case.) Since in nginx TCP_DEFER_ACCEPT is set to "post_accept_timeout", we do not need to wait longer if deferred accept returns with no data.
* Use "client_header_timeout" for all requests in a connection.Valentin Bartenev2013-03-07
| | | | | | | | | | | Previously, only the first request in a connection used timeout value from the "client_header_timeout" directive while reading header. All subsequent requests used "keepalive_timeout" for that. It happened because timeout of the read event was set to the value of "keepalive_timeout" in ngx_http_set_keepalive(), but was not removed when the next request arrived.
* Create request object only after the first byte was received.Valentin Bartenev2013-03-07
| | | | | | | | | | | | | Previously, we always created an object and logged 400 (Bad Request) in access log if a client closed connection without sending any data. Such a connection was counted as "reading". Since it's common for modern browsers to behave like this, it's no longer considered an error if a client closes connection without sending any data, and such a connection will be counted as "waiting". Now, we do not log 400 (Bad Request) and keep memory footprint as small as possible.
* Allocate request object from its own pool.Valentin Bartenev2013-03-01
| | | | | | | | Previously, it was allocated from a connection pool and was selectively freed for an idle keepalive connection. The goal is to put coupled things in one chunk of memory, and to simplify handling of request objects.
* SNI: added restriction on requesting host other than negotiated.Valentin Bartenev2013-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC 6066, client is not supposed to request a different server name at the application layer. Server implementations that rely upon these names being equal must validate that a client did not send a different name in HTTP request. Current versions of Apache HTTP server always return 400 "Bad Request" in such cases. There exist implementations however (e.g., SPDY) that rely on being able to request different host names in one connection. Given this, we only reject requests with differing host names if verification of client certificates is enabled in a corresponding server configuration. An example of configuration that might not work as expected: server { listen 433 ssl default; return 404; } server { listen 433 ssl; server_name example.org; ssl_client_certificate org.cert; ssl_verify_client on; } server { listen 433 ssl; server_name example.com; ssl_client_certificate com.cert; ssl_verify_client on; } Previously, a client was able to request example.com by presenting a certificate for example.org, and vice versa.
* SNI: reset to default server if requested host was not found.Valentin Bartenev2013-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | Not only this is consistent with a case without SNI, but this also prevents abusing configurations that assume that the $host variable is limited to one of the configured names for a server. An example of potentially unsafe configuration: server { listen 443 ssl default_server; ... } server { listen 443; server_name example.com; location / { proxy_pass http://$host; } } Note: it is possible to negotiate "example.com" by SNI, and to request arbitrary host name that does not exist in the configuration above.
* SNI: avoid surplus lookup of virtual server if SNI was used.Valentin Bartenev2013-02-27
|