summaryrefslogtreecommitdiffhomepage
path: root/src/http/v2 (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-11-02HTTP/2: flow control debugging.Sergey Kandaurov1-0/+4
2016-10-31HTTP/2: slightly improved debugging.Ruslan Ermilov1-3/+4
2016-10-31HTTP/2: limited maximum number of requests in connection.Valentin Bartenev3-8/+32
The new directive "http2_max_requests" is introduced. From users point of view it works quite similar to "keepalive_requests" but has significantly bigger default value that is more suitable for HTTP/2.
2016-10-20HTTP/2: graceful shutdown of active connections (closes #1106).Valentin Bartenev2-9/+39
Previously, while shutting down gracefully, the HTTP/2 connections were closed in transition to idle state after all active streams have been processed. That might never happen if the client continued opening new streams. Now, nginx sends GOAWAY to all HTTP/2 connections and ignores further attempts to open new streams. A worker process will quit as soon as processing of already opened streams is finished.
2016-10-10Allowed '-' in method names.Maxim Dounin1-1/+1
It is used at least by SOAP (M-POST method, defined by RFC 2774) and by WebDAV versioning (VERSION-CONTROL and BASELINE-CONTROL methods, defined by RFC 3253).
2016-07-19HTTP/2: flushing of the SSL buffer in transition to the idle state.Valentin Bartenev1-2/+18
It fixes potential connection leak if some unsent data was left in the SSL buffer. Particularly, that could happen when a client canceled the stream after the HEADERS frame has already been created. In this case no other frames might be produced and the HEADERS frame alone didn't flush the buffer.
2016-07-19HTTP/2: refactored ngx_http_v2_send_output_queue().Valentin Bartenev1-10/+10
Now it returns NGX_AGAIN if there's still data to be sent.
2016-07-19HTTP/2: fixed send timer handling.Valentin Bartenev1-1/+1
Checking for return value of c->send_chain() isn't sufficient since there are data can be left in the SSL buffer. Now the wew->ready flag is used instead. In particular, this fixed a connection leak in cases when all streams were closed, but there's still some data to be sent in the SSL buffer and the client forgot about the connection.
2016-07-19HTTP/2: avoid sending output queue if there's nothing to send.Valentin Bartenev1-0/+10
Particularly this fixes alerts on OS X and NetBSD systems when HTTP/2 is configured over plain TCP sockets. On these systems calling writev() with no data leads to EINVAL errors being logged as "writev() failed (22: Invalid argument) while processing HTTP/2 connection".
2016-07-19HTTP/2: always handle streams in error state.Valentin Bartenev1-6/+8
Previously, a stream could be closed by timeout if it was canceled while its send window was exhausted.
2016-07-19HTTP/2: prevented output of the HEADERS frame for canceled streams.Valentin Bartenev1-2/+6
It's useless to generate HEADERS if the stream has been canceled already.
2016-07-19HTTP/2: always send GOAWAY while worker is shutting down.Valentin Bartenev1-1/+1
Previously, if the worker process exited, GOAWAY was sent to connections in idle state, but connections with active streams were closed without GOAWAY.
2016-07-07HTTP/2: avoid left-shifting signed integer into the sign bit.Sergey Kandaurov1-1/+1
On non-aligned platforms, properly cast argument before left-shifting it in ngx_http_v2_parse_uint32 that is used with u_char. Otherwise it propagates to int to hold the value and can step over the sign bit. Usually, on known compilers, this results in negation. Furthermore, a subsequent store into a wider type, that is ngx_uint_t on 64-bit platforms, results in sign-extension. In practice, this can be observed in debug log as a very large exclusive bit value, when client sent PRIORITY frame with exclusive bit set: : *14 http2 PRIORITY frame sid:5 on 1 excl:8589934591 weight:17 Found with UndefinedBehaviorSanitizer.
2016-06-22HTTP/2: style.Piotr Sikora1-6/+4
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-20Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan1-22/+1
2016-06-16HTTP/2: fixed the "http request count is zero" alert.Valentin Bartenev1-0/+1
When the stream is terminated the HEADERS frame can still wait in the output queue. This frame can't be removed and must be sent to the client anyway, since HTTP/2 uses stateful compression for headers. So in order to postpone closing and freeing memory of such stream the special close stream handler is set to the write event. After the HEADERS frame is sent the write event is called and the stream will be finally closed. Some events like receiving a RST_STREAM can trigger the read handler of such stream in closing state and cause unexpected processing that can result in another attempt to finalize the request. To prevent it the read handler is now set to ngx_http_empty_handler. Thanks to Amazon.
2016-06-16HTTP/2: avoid adding Content-Length for requests without body.Valentin Bartenev1-2/+4
There is no reason to add the "Content-Length: 0" header to a proxied request without body if the header isn't presented in the original request. Thanks to Amazon.
2016-06-16HTTP/2: prevented double termination of a stream.Valentin Bartenev1-0/+5
According to RFC 7540, an endpoint should not send more than one RST_STREAM frame for any stream. Also, now all the data frames will be skipped while termination.
2016-06-16HTTP/2: fixed a segfault while processing unbuffered upload.Valentin Bartenev1-4/+0
The ngx_http_v2_finalize_connection() closes current stream, but that is an invalid operation while processing unbuffered upload. This results in access to already freed memory, since the upstream module sets a cleanup handler that also finalizes the request.
2016-05-24HTTP/2: unbreak build on MSVC.Valentin Bartenev1-1/+1
2016-05-24HTTP/2: implemented preread buffer for request body (closes #959).Valentin Bartenev4-43/+146
Previously, the stream's window was kept zero in order to prevent a client from sending the request body before it was requested (see 887cca40ba6a for details). Until such initial window was acknowledged all requests with data were rejected (see 0aa07850922f for details). That approach revealed a number of problems: 1. Some clients (notably MS IE/Edge, Safari, iOS applications) show an error or even crash if a stream is rejected; 2. This requires at least one RTT for every request with body before the client receives window update and able to send data. To overcome these problems the new directive "http2_body_preread_size" is introduced. It sets the initial window and configures a special per stream preread buffer that is used to save all incoming data before the body is requested and processed. If the directive's value is lower than the default initial window (65535), as previously, all streams with data will be rejected until the new window is acknowledged. Otherwise, no special processing is used and all requests with data are welcome right from the connection start. The default value is chosen to be 64k, which is bigger than the default initial window. Setting it to zero is fully complaint to the previous behavior.
2016-04-19HTTP/2: send the output queue after emitting WINDOW_UPDATE.Valentin Bartenev1-0/+10
The WINDOW_UPDATE frame could be left in the output queue for an indefinite period of time resulting in the request timeout. This might happen if reading of the body was triggered by an event unrelated to client connection, e.g. by the limit_req timer.
2016-04-19HTTP/2: skip data frames in case of internal errors.Valentin Bartenev1-0/+2
This prevents possible processing of such frames and triggering rb->post_handler if an error occurred during r->request_body initialization.
2016-04-19HTTP/2: don't send WINDOW_UPDATE for an empty request body.Valentin Bartenev1-12/+13
Particularly this prevents sending WINDOW_UPDATE with zero delta which can result in PROTOCOL_ERROR. Also removed surplus setting of no_flow_control to 0.
2016-04-18HTTP/2: write logs when refusing streams with data.Maxim Dounin1-0/+4
Refusing streams is known to be incorrectly handled at least by IE, Edge and Safari. Make sure to provide appropriate logging to simplify fixing this in the affected browsers.
2016-04-14HTTP/2: send WINDOW_UPDATE instead of RST_STREAM with NO_ERROR.Valentin Bartenev1-0/+22
After the 92464ebace8e change, it has been discovered that not all clients follow the RFC and handle RST_STREAM with NO_ERROR properly. Notably, Chrome currently interprets it as INTERNAL_ERROR and discards the response. As a workaround, instead of RST_STREAM the maximum stream window update will be sent, which will let client to send up to 2 GB of a request body data before getting stuck on flow control. All the received data will be silently discarded. See for details: http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008143.html https://bugs.chromium.org/p/chromium/issues/detail?id=603182
2016-04-14HTTP/2: refuse streams with data until SETTINGS is acknowledged.Valentin Bartenev2-1/+8
A client is allowed to send requests before receiving and acknowledging the SETTINGS frame. Such a client having a wrong idea about the stream's could send the request body that nginx isn't ready to process. The previous behavior was to send RST_STREAM with FLOW_CONTROL_ERROR in such case, but it didn't allow retrying requests that have been rejected.
2016-04-14HTTP/2: deduplicated some code in ngx_http_v2_state_headers().Valentin Bartenev1-18/+13
No functional changes.
2016-04-01HTTP/2: support for unbuffered upload of request body.Valentin Bartenev2-2/+126
2016-04-01HTTP/2: rewritten handling of request body.Valentin Bartenev2-246/+223
There are two improvements: 1. Support for request body filters; 2. Receiving of request body is started only after the ngx_http_read_client_request_body() call. The last one fixes the problem when the client_max_body_size value might not be respected from the right location if the location was changed either during the process of receiving body or after the whole body had been received.
2016-04-01HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.Valentin Bartenev2-14/+25
RFC 7540 states that "A server can send a complete response prior to the client sending an entire request if the response does not depend on any portion of the request that has not been sent and received. When this is true, a server MAY request that the client abort transmission of a request without error by sending a RST_STREAM with an error code of NO_ERROR after sending a complete response (i.e., a frame with the END_STREAM flag)." This should prevent a client from blocking on the stream window, since it isn't maintained for closed streams. Currently, quite big initial stream windows are used, so such blocking is very unlikly, but that will be changed in the further patches.
2016-03-31Fixed logging.Sergey Kandaurov1-1/+1
2016-03-30Style.Ruslan Ermilov1-1/+1
2016-03-22Backed out server_tokens changes.Maxim Dounin1-43/+9
Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
2016-03-22Reconsidered server_tokens with an empty value.Ruslan Ermilov1-4/+4
An empty value will be treated as "off".
2016-03-21HTTP/2: improved debugging of sending control frames.Valentin Bartenev1-2/+13
2016-03-15Win32: fixed build after cf3e75cfa951.Ruslan Ermilov1-0/+4
2016-03-15Added variables support to server_tokens.Ruslan Ermilov1-10/+40
It can now be set to "off" conditionally, e.g. using the map directive. An empty value will disable the emission of the Server: header and the signature in error messages generated by nginx. Any other value is treated as "on", meaning that full nginx version is emitted in the Server: header and error messages generated by nginx.
2016-02-24HTTP/2: implemented per request timeouts (closes #626).Valentin Bartenev2-51/+147
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.
2016-02-24HTTP/2: always use temporary pool for processing headers.Valentin Bartenev2-25/+37
This is required for implementing per request timeouts. Previously, the temporary pool was used only during skipping of headers and the request pool was used otherwise. That required switching of pools if the request was closed while parsing. It wasn't a problem since the request could be closed only after the validation of the fully parsed header. With the per request timeouts, the request can be closed at any moment, and switching of pools in the middle of parsing header name or value becomes a problem. To overcome this, the temporary pool is now always created and used. Special checks are added to keep it when either the stream is being processed or until header block is fully parsed.
2016-02-24HTTP/2: cleaned up state while closing stream.Valentin Bartenev1-0/+4
Without this the state might keep pointing to already closed stream.
2016-02-16HTTP/2: added debug logging of response headers.Valentin Bartenev1-0/+41
Because of HPACK compression it's hard to see what headers are actually sent by the server.
2016-02-16HTTP/2: use local pointer instead of r->connection.Valentin Bartenev1-2/+2
No functional changes.
2016-02-12HTTP/2: fixed undefined behavior in ngx_http_v2_huff_encode().Valentin Bartenev1-2/+6
When the "pending" value is zero, the "buf" will be right shifted by the width of its type, which results in undefined behavior. Found by Coverity (CID 1352150).
2016-02-11HTTP/2: implemented HPACK Huffman encoding for response headers.Valentin Bartenev3-56/+343
This reduces the size of headers by over 30% on average. Based on the patch by Vlad Krasnov: http://mailman.nginx.org/pipermail/nginx-devel/2015-December/007682.html
2016-02-04HTTP/2: fixed possible buffer overrun (ticket #893).Valentin Bartenev1-2/+2
Due to greater priority of the unary plus operator over the ternary operator the expression didn't work as expected. That might result in one byte less allocation than needed for the HEADERS frame buffer.
2016-02-02HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.Valentin Bartenev1-1/+11
2016-02-02HTTP/2: fixed request length accounting.Valentin Bartenev1-1/+10
Now it includes not only the received body size, but the size of headers block as well.
2016-02-02HTTP/2: fixed excessive memory allocation for pool cleanup.Valentin Bartenev1-1/+1
2016-02-02HTTP/2: removed unused field from ngx_http_v2_stream_t.Valentin Bartenev1-1/+0