Mercurial > hg > nginx
comparison src/http/v2/ngx_http_v2.h @ 6566:ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
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.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Tue, 24 May 2016 17:37:52 +0300 |
parents | 0aa07850922f |
children | ad736705a744 09cf90250844 |
comparison
equal
deleted
inserted
replaced
6565:3af0e65a461a | 6566:ce94f07d5082 |
---|---|
43 #define NGX_HTTP_V2_ACK_FLAG 0x01 | 43 #define NGX_HTTP_V2_ACK_FLAG 0x01 |
44 #define NGX_HTTP_V2_END_STREAM_FLAG 0x01 | 44 #define NGX_HTTP_V2_END_STREAM_FLAG 0x01 |
45 #define NGX_HTTP_V2_END_HEADERS_FLAG 0x04 | 45 #define NGX_HTTP_V2_END_HEADERS_FLAG 0x04 |
46 #define NGX_HTTP_V2_PADDED_FLAG 0x08 | 46 #define NGX_HTTP_V2_PADDED_FLAG 0x08 |
47 #define NGX_HTTP_V2_PRIORITY_FLAG 0x20 | 47 #define NGX_HTTP_V2_PRIORITY_FLAG 0x20 |
48 | |
49 #define NGX_HTTP_V2_MAX_WINDOW ((1U << 31) - 1) | |
50 #define NGX_HTTP_V2_DEFAULT_WINDOW 65535 | |
48 | 51 |
49 | 52 |
50 typedef struct ngx_http_v2_connection_s ngx_http_v2_connection_t; | 53 typedef struct ngx_http_v2_connection_s ngx_http_v2_connection_t; |
51 typedef struct ngx_http_v2_node_s ngx_http_v2_node_t; | 54 typedef struct ngx_http_v2_node_s ngx_http_v2_node_t; |
52 typedef struct ngx_http_v2_out_frame_s ngx_http_v2_out_frame_t; | 55 typedef struct ngx_http_v2_out_frame_s ngx_http_v2_out_frame_t; |
172 * send_window to become negative, hence it's signed. | 175 * send_window to become negative, hence it's signed. |
173 */ | 176 */ |
174 ssize_t send_window; | 177 ssize_t send_window; |
175 size_t recv_window; | 178 size_t recv_window; |
176 | 179 |
180 ngx_buf_t *preread; | |
181 | |
177 ngx_http_v2_out_frame_t *free_frames; | 182 ngx_http_v2_out_frame_t *free_frames; |
178 ngx_chain_t *free_frame_headers; | 183 ngx_chain_t *free_frame_headers; |
179 ngx_chain_t *free_bufs; | 184 ngx_chain_t *free_bufs; |
180 | 185 |
181 ngx_queue_t queue; | 186 ngx_queue_t queue; |