Mercurial > hg > nginx
annotate src/http/v2/ngx_http_v2.c @ 9119:08ef02ad5c54
HTTP/2: "http2" directive.
The directive enables HTTP/2 in the current server. The previous way to
enable HTTP/2 via "listen ... http2" is now deprecated. The new approach
allows to share HTTP/2 and HTTP/0.9-1.1 on the same port.
For SSL connections, HTTP/2 is now selected by ALPN callback based on whether
the protocol is enabled in the virtual server chosen by SNI. This however only
works since OpenSSL 1.0.2h, where ALPN callback is invoked after SNI callback.
For older versions of OpenSSL, HTTP/2 is enabled based on the default virtual
server configuration.
For plain TCP connections, HTTP/2 is now auto-detected by HTTP/2 preface, if
HTTP/2 is enabled in the default virtual server. If preface is not matched,
HTTP/0.9-1.1 is assumed.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 16 May 2023 16:30:08 +0400 |
parents | 9db24374123b |
children | 262c01782566 |
rev | line source |
---|---|
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4 * Copyright (C) Valentin V. Bartenev |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
6 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
7 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_http_v2_module.h> |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
12 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
13 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
14 typedef struct { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
15 ngx_str_t name; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
16 ngx_uint_t offset; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
17 ngx_uint_t hash; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
18 ngx_http_header_t *hh; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
19 } ngx_http_v2_parse_header_t; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
20 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
21 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
22 /* errors */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
23 #define NGX_HTTP_V2_NO_ERROR 0x0 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
24 #define NGX_HTTP_V2_PROTOCOL_ERROR 0x1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
25 #define NGX_HTTP_V2_INTERNAL_ERROR 0x2 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
26 #define NGX_HTTP_V2_FLOW_CTRL_ERROR 0x3 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
27 #define NGX_HTTP_V2_SETTINGS_TIMEOUT 0x4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
28 #define NGX_HTTP_V2_STREAM_CLOSED 0x5 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
29 #define NGX_HTTP_V2_SIZE_ERROR 0x6 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
30 #define NGX_HTTP_V2_REFUSED_STREAM 0x7 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
31 #define NGX_HTTP_V2_CANCEL 0x8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
32 #define NGX_HTTP_V2_COMP_ERROR 0x9 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
33 #define NGX_HTTP_V2_CONNECT_ERROR 0xa |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
34 #define NGX_HTTP_V2_ENHANCE_YOUR_CALM 0xb |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
35 #define NGX_HTTP_V2_INADEQUATE_SECURITY 0xc |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
36 #define NGX_HTTP_V2_HTTP_1_1_REQUIRED 0xd |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
37 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
38 /* frame sizes */ |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
39 #define NGX_HTTP_V2_SETTINGS_ACK_SIZE 0 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
40 #define NGX_HTTP_V2_RST_STREAM_SIZE 4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
41 #define NGX_HTTP_V2_PRIORITY_SIZE 5 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
42 #define NGX_HTTP_V2_PING_SIZE 8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
43 #define NGX_HTTP_V2_GOAWAY_SIZE 8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
44 #define NGX_HTTP_V2_WINDOW_UPDATE_SIZE 4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
45 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
46 #define NGX_HTTP_V2_SETTINGS_PARAM_SIZE 6 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
47 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
48 /* settings fields */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
49 #define NGX_HTTP_V2_HEADER_TABLE_SIZE_SETTING 0x1 |
7201 | 50 #define NGX_HTTP_V2_ENABLE_PUSH_SETTING 0x2 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
51 #define NGX_HTTP_V2_MAX_STREAMS_SETTING 0x3 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
52 #define NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING 0x4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
53 #define NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING 0x5 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
54 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
55 #define NGX_HTTP_V2_FRAME_BUFFER_SIZE 24 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
56 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
57 #define NGX_HTTP_V2_ROOT (void *) -1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
58 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
59 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
60 static void ngx_http_v2_read_handler(ngx_event_t *rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
61 static void ngx_http_v2_write_handler(ngx_event_t *wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
62 static void ngx_http_v2_handle_connection(ngx_http_v2_connection_t *h2c); |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
63 static void ngx_http_v2_lingering_close(ngx_connection_t *c); |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
64 static void ngx_http_v2_lingering_close_handler(ngx_event_t *rev); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
65 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
66 static u_char *ngx_http_v2_state_preface(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
67 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
68 static u_char *ngx_http_v2_state_preface_end(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
69 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
70 static u_char *ngx_http_v2_state_head(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
71 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
72 static u_char *ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
73 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
74 static u_char *ngx_http_v2_state_read_data(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
75 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
76 static u_char *ngx_http_v2_state_headers(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
77 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
78 static u_char *ngx_http_v2_state_header_block(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
79 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
80 static u_char *ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
81 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
82 static u_char *ngx_http_v2_state_field_huff(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
83 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
84 static u_char *ngx_http_v2_state_field_raw(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
85 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
86 static u_char *ngx_http_v2_state_field_skip(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
87 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
88 static u_char *ngx_http_v2_state_process_header(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
89 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
90 static u_char *ngx_http_v2_state_header_complete(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
91 u_char *pos, u_char *end); |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
92 static u_char *ngx_http_v2_handle_continuation(ngx_http_v2_connection_t *h2c, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
93 u_char *pos, u_char *end, ngx_http_v2_handler_pt handler); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
94 static u_char *ngx_http_v2_state_priority(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
95 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
96 static u_char *ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
97 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
98 static u_char *ngx_http_v2_state_settings(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
99 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
100 static u_char *ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
101 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
102 static u_char *ngx_http_v2_state_push_promise(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
103 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
104 static u_char *ngx_http_v2_state_ping(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
105 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
106 static u_char *ngx_http_v2_state_goaway(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
107 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
108 static u_char *ngx_http_v2_state_window_update(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
109 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
110 static u_char *ngx_http_v2_state_continuation(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
111 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
112 static u_char *ngx_http_v2_state_complete(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
113 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
114 static u_char *ngx_http_v2_state_skip_padded(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
115 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
116 static u_char *ngx_http_v2_state_skip(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
117 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
118 static u_char *ngx_http_v2_state_save(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
119 u_char *pos, u_char *end, ngx_http_v2_handler_pt handler); |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
120 static u_char *ngx_http_v2_state_headers_save(ngx_http_v2_connection_t *h2c, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
121 u_char *pos, u_char *end, ngx_http_v2_handler_pt handler); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
122 static u_char *ngx_http_v2_connection_error(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
123 ngx_uint_t err); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
124 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
125 static ngx_int_t ngx_http_v2_parse_int(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
126 u_char **pos, u_char *end, ngx_uint_t prefix); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
127 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
128 static ngx_http_v2_stream_t *ngx_http_v2_create_stream( |
7201 | 129 ngx_http_v2_connection_t *h2c, ngx_uint_t push); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
130 static ngx_http_v2_node_t *ngx_http_v2_get_node_by_id( |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
131 ngx_http_v2_connection_t *h2c, ngx_uint_t sid, ngx_uint_t alloc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
132 static ngx_http_v2_node_t *ngx_http_v2_get_closed_node( |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
133 ngx_http_v2_connection_t *h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
134 #define ngx_http_v2_index_size(h2scf) (h2scf->streams_index_mask + 1) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
135 #define ngx_http_v2_index(h2scf, sid) ((sid >> 1) & h2scf->streams_index_mask) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
136 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
137 static ngx_int_t ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
138 static ngx_int_t ngx_http_v2_settings_frame_handler( |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
139 ngx_http_v2_connection_t *h2c, ngx_http_v2_out_frame_t *frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
140 static ngx_int_t ngx_http_v2_send_window_update(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
141 ngx_uint_t sid, size_t window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
142 static ngx_int_t ngx_http_v2_send_rst_stream(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
143 ngx_uint_t sid, ngx_uint_t status); |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
144 static ngx_int_t ngx_http_v2_send_goaway(ngx_http_v2_connection_t *h2c, |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
145 ngx_uint_t status); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
146 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
147 static ngx_http_v2_out_frame_t *ngx_http_v2_get_frame( |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
148 ngx_http_v2_connection_t *h2c, size_t length, ngx_uint_t type, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
149 u_char flags, ngx_uint_t sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
150 static ngx_int_t ngx_http_v2_frame_handler(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
151 ngx_http_v2_out_frame_t *frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
152 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
153 static ngx_int_t ngx_http_v2_validate_header(ngx_http_request_t *r, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
154 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
155 static ngx_int_t ngx_http_v2_pseudo_header(ngx_http_request_t *r, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
156 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
157 static ngx_int_t ngx_http_v2_parse_path(ngx_http_request_t *r, |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
158 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
159 static ngx_int_t ngx_http_v2_parse_method(ngx_http_request_t *r, |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
160 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
161 static ngx_int_t ngx_http_v2_parse_scheme(ngx_http_request_t *r, |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
162 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
163 static ngx_int_t ngx_http_v2_parse_authority(ngx_http_request_t *r, |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
164 ngx_str_t *value); |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
165 static ngx_int_t ngx_http_v2_parse_header(ngx_http_request_t *r, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
166 ngx_http_v2_parse_header_t *header, ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
167 static ngx_int_t ngx_http_v2_construct_request_line(ngx_http_request_t *r); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
168 static ngx_int_t ngx_http_v2_cookie(ngx_http_request_t *r, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
169 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
170 static ngx_int_t ngx_http_v2_construct_cookie_header(ngx_http_request_t *r); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
171 static void ngx_http_v2_run_request(ngx_http_request_t *r); |
7201 | 172 static void ngx_http_v2_run_request_handler(ngx_event_t *ev); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
173 static ngx_int_t ngx_http_v2_process_request_body(ngx_http_request_t *r, |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
174 u_char *pos, size_t size, ngx_uint_t last, ngx_uint_t flush); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
175 static ngx_int_t ngx_http_v2_filter_request_body(ngx_http_request_t *r); |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
176 static void ngx_http_v2_read_client_request_body_handler(ngx_http_request_t *r); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
177 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
178 static ngx_int_t ngx_http_v2_terminate_stream(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
179 ngx_http_v2_stream_t *stream, ngx_uint_t status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
180 static void ngx_http_v2_close_stream_handler(ngx_event_t *ev); |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
181 static void ngx_http_v2_retry_close_stream_handler(ngx_event_t *ev); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
182 static void ngx_http_v2_handle_connection_handler(ngx_event_t *rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
183 static void ngx_http_v2_idle_handler(ngx_event_t *rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
184 static void ngx_http_v2_finalize_connection(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
185 ngx_uint_t status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
186 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
187 static ngx_int_t ngx_http_v2_adjust_windows(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
188 ssize_t delta); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
189 static void ngx_http_v2_set_dependency(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
190 ngx_http_v2_node_t *node, ngx_uint_t depend, ngx_uint_t exclusive); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
191 static void ngx_http_v2_node_children_update(ngx_http_v2_node_t *node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
192 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
193 static void ngx_http_v2_pool_cleanup(void *data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
194 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
195 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
196 static ngx_http_v2_handler_pt ngx_http_v2_frame_states[] = { |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
197 ngx_http_v2_state_data, /* NGX_HTTP_V2_DATA_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
198 ngx_http_v2_state_headers, /* NGX_HTTP_V2_HEADERS_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
199 ngx_http_v2_state_priority, /* NGX_HTTP_V2_PRIORITY_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
200 ngx_http_v2_state_rst_stream, /* NGX_HTTP_V2_RST_STREAM_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
201 ngx_http_v2_state_settings, /* NGX_HTTP_V2_SETTINGS_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
202 ngx_http_v2_state_push_promise, /* NGX_HTTP_V2_PUSH_PROMISE_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
203 ngx_http_v2_state_ping, /* NGX_HTTP_V2_PING_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
204 ngx_http_v2_state_goaway, /* NGX_HTTP_V2_GOAWAY_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
205 ngx_http_v2_state_window_update, /* NGX_HTTP_V2_WINDOW_UPDATE_FRAME */ |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
206 ngx_http_v2_state_continuation /* NGX_HTTP_V2_CONTINUATION_FRAME */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
207 }; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
208 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
209 #define NGX_HTTP_V2_FRAME_STATES \ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
210 (sizeof(ngx_http_v2_frame_states) / sizeof(ngx_http_v2_handler_pt)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
211 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
212 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
213 static ngx_http_v2_parse_header_t ngx_http_v2_parse_headers[] = { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
214 { ngx_string("host"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
215 offsetof(ngx_http_headers_in_t, host), 0, NULL }, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
216 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
217 { ngx_string("accept-encoding"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
218 offsetof(ngx_http_headers_in_t, accept_encoding), 0, NULL }, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
219 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
220 { ngx_string("accept-language"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
221 offsetof(ngx_http_headers_in_t, accept_language), 0, NULL }, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
222 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
223 { ngx_string("user-agent"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
224 offsetof(ngx_http_headers_in_t, user_agent), 0, NULL }, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
225 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
226 { ngx_null_string, 0, 0, NULL } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
227 }; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
228 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
229 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
230 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
231 ngx_http_v2_init(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
232 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
233 u_char *p, *end; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
234 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
235 ngx_pool_cleanup_t *cln; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
236 ngx_http_connection_t *hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
237 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
238 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
239 ngx_http_v2_connection_t *h2c; |
7783
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
240 ngx_http_core_srv_conf_t *cscf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
241 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
242 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
243 hc = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
244 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
245 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "init http2 connection"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
246 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
247 c->log->action = "processing HTTP/2 connection"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
248 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
249 h2mcf = ngx_http_get_module_main_conf(hc->conf_ctx, ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
250 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
251 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
252 h2mcf->recv_buffer = ngx_palloc(ngx_cycle->pool, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
253 h2mcf->recv_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
254 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
255 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
256 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
257 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
258 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
259 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
260 h2c = ngx_pcalloc(c->pool, sizeof(ngx_http_v2_connection_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
261 if (h2c == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
262 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
263 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
264 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
265 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
266 h2c->connection = c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
267 h2c->http_connection = hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
268 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
269 h2c->send_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
270 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
271 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
272 h2c->init_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
273 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
274 h2c->frame_size = NGX_HTTP_V2_DEFAULT_FRAME_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
275 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
276 h2scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
277 |
7201 | 278 h2c->concurrent_pushes = h2scf->concurrent_pushes; |
7819
3674d5b7174e
HTTP/2: relaxed PRIORITY frames limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7805
diff
changeset
|
279 h2c->priority_limit = ngx_max(h2scf->concurrent_streams, 100); |
7201 | 280 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
281 h2c->pool = ngx_create_pool(h2scf->pool_size, h2c->connection->log); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
282 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
283 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
284 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
285 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
286 |
6374
f598de1bfcd4
HTTP/2: fixed excessive memory allocation for pool cleanup.
Valentin Bartenev <vbart@nginx.com>
parents:
6312
diff
changeset
|
287 cln = ngx_pool_cleanup_add(c->pool, 0); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
288 if (cln == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
289 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
290 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
291 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
292 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
293 cln->handler = ngx_http_v2_pool_cleanup; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
294 cln->data = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
295 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
296 h2c->streams_index = ngx_pcalloc(c->pool, ngx_http_v2_index_size(h2scf) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
297 * sizeof(ngx_http_v2_node_t *)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
298 if (h2c->streams_index == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
299 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
300 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
301 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
302 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
303 if (ngx_http_v2_send_settings(h2c) == NGX_ERROR) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
304 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
305 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
306 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
307 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
308 if (ngx_http_v2_send_window_update(h2c, 0, NGX_HTTP_V2_MAX_WINDOW |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
309 - NGX_HTTP_V2_DEFAULT_WINDOW) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
310 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
311 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
312 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
313 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
314 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
315 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
316 h2c->state.handler = ngx_http_v2_state_preface; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
317 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
318 ngx_queue_init(&h2c->waiting); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
319 ngx_queue_init(&h2c->dependencies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
320 ngx_queue_init(&h2c->closed); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
321 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
322 c->data = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
323 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
324 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
325 c->write->handler = ngx_http_v2_write_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
326 |
7783
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
327 if (!rev->timer_set) { |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
328 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
329 ngx_http_core_module); |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
330 ngx_add_timer(rev, cscf->client_header_timeout); |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
331 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
332 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
333 c->idle = 1; |
7769
0a5687a458de
HTTP/2: fixed reusing connections with active requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7768
diff
changeset
|
334 ngx_reusable_connection(c, 0); |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
335 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
336 if (c->buffer) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
337 p = c->buffer->pos; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
338 end = c->buffer->last; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
339 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
340 do { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
341 p = h2c->state.handler(h2c, p, end); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
342 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
343 if (p == NULL) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
344 return; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
345 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
346 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
347 } while (p != end); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
348 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
349 h2c->total_bytes += p - c->buffer->pos; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
350 c->buffer->pos = p; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
351 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
352 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
353 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
354 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
355 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
356 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
357 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
358 ngx_http_v2_read_handler(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
359 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
360 u_char *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
361 size_t available; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
362 ssize_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
363 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
364 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
365 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
366 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
367 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
368 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
369 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
370 if (rev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
371 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
372 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
373 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
374 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
375 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
376 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http2 read handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
377 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
378 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
379 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
380 if (c->close) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
381 c->close = 0; |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
382 |
7571
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
383 if (c->error) { |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
384 ngx_http_v2_finalize_connection(h2c, 0); |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
385 return; |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
386 } |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
387 |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
388 if (!h2c->processing && !h2c->pushing) { |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
389 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR); |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
390 return; |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
391 } |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
392 |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
393 if (!h2c->goaway) { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
394 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
395 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
396 if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
397 == NGX_ERROR) |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
398 { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
399 ngx_http_v2_finalize_connection(h2c, 0); |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
400 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
401 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
402 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
403 if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
404 ngx_http_v2_finalize_connection(h2c, 0); |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
405 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
406 } |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
407 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
408 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
409 h2c->blocked = 0; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
410 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
411 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
412 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
413 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
414 h2mcf = ngx_http_get_module_main_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
415 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
416 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
417 available = h2mcf->recv_buffer_size - 2 * NGX_HTTP_V2_STATE_BUFFER_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
418 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
419 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
420 p = h2mcf->recv_buffer; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
421 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
422 ngx_memcpy(p, h2c->state.buffer, NGX_HTTP_V2_STATE_BUFFER_SIZE); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
423 end = p + h2c->state.buffer_used; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
424 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
425 n = c->recv(c, end, available); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
426 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
427 if (n == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
428 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
429 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
430 |
7201 | 431 if (n == 0 |
432 && (h2c->state.incomplete || h2c->processing || h2c->pushing)) | |
433 { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
434 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
435 "client prematurely closed connection"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
436 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
437 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
438 if (n == 0 || n == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
439 c->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
440 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
441 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
442 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
443 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
444 end += n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
445 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
446 h2c->state.buffer_used = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
447 h2c->state.incomplete = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
448 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
449 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
450 p = h2c->state.handler(h2c, p, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
451 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
452 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
453 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
454 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
455 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
456 } while (p != end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
457 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
458 h2c->total_bytes += n; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
459 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
460 if (h2c->total_bytes / 8 > h2c->payload_bytes + 1048576) { |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
461 ngx_log_error(NGX_LOG_INFO, c->log, 0, "http2 flood detected"); |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
462 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR); |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
463 return; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
464 } |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
465 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
466 } while (rev->ready); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
467 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
468 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
469 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
470 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
471 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
472 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
473 if (h2c->last_out && ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
474 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
475 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
476 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
477 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
478 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
479 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
480 ngx_http_v2_handle_connection(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
481 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
482 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
483 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
484 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
485 ngx_http_v2_write_handler(ngx_event_t *wev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
486 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
487 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
488 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
489 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
490 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
491 c = wev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
492 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
493 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
494 if (wev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
495 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
496 "http2 write event timed out"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
497 c->error = 1; |
7695
d57f15922ca3
HTTP/2: fixed c->timedout flag on timed out connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7673
diff
changeset
|
498 c->timedout = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
499 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
500 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
501 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
502 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
503 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http2 write handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
504 |
6639
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
505 if (h2c->last_out == NULL && !c->buffered) { |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
506 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
507 if (wev->timer_set) { |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
508 ngx_del_timer(wev); |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
509 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
510 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
511 ngx_http_v2_handle_connection(h2c); |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
512 return; |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
513 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
514 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
515 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
516 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
517 rc = ngx_http_v2_send_output_queue(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
518 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
519 if (rc == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
520 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
521 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
522 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
523 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
524 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
525 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
526 if (rc == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
527 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
528 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
529 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
530 ngx_http_v2_handle_connection(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
531 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
532 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
533 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
534 ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
535 ngx_http_v2_send_output_queue(ngx_http_v2_connection_t *h2c) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
536 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
537 int tcp_nodelay; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
538 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
539 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
540 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 ngx_http_v2_out_frame_t *out, *frame, *fn; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
542 ngx_http_core_loc_conf_t *clcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
543 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
544 c = h2c->connection; |
7570
d6cf51af8a3d
HTTP/2: fixed possible alert about left open socket on shutdown.
Ruslan Ermilov <ru@nginx.com>
parents:
7569
diff
changeset
|
545 wev = c->write; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
546 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
547 if (c->error) { |
7570
d6cf51af8a3d
HTTP/2: fixed possible alert about left open socket on shutdown.
Ruslan Ermilov <ru@nginx.com>
parents:
7569
diff
changeset
|
548 goto error; |
d6cf51af8a3d
HTTP/2: fixed possible alert about left open socket on shutdown.
Ruslan Ermilov <ru@nginx.com>
parents:
7569
diff
changeset
|
549 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
550 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
551 if (!wev->ready) { |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
552 return NGX_AGAIN; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
553 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
554 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
555 cl = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
556 out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
557 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 for (frame = h2c->last_out; frame; frame = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
559 frame->last->next = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
560 cl = frame->first; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
561 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
562 fn = frame->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
563 frame->next = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
564 out = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
565 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
566 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
567 "http2 frame out: %p sid:%ui bl:%d len:%uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
568 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
569 out->blocked, out->length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
570 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
571 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
572 cl = c->send_chain(c, cl, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
573 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 if (cl == NGX_CHAIN_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
577 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
578 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
579 ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
580 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
583 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
584 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
585 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
586 if (ngx_tcp_push(c->fd) == -1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
588 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
589 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
590 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
591 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
592 tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
593 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
594 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
595 tcp_nodelay = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
596 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
597 |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6989
diff
changeset
|
598 if (tcp_nodelay && clcf->tcp_nodelay && ngx_tcp_nodelay(c) != NGX_OK) { |
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6989
diff
changeset
|
599 goto error; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
600 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
601 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
602 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
603 fn = out->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
605 if (out->handler(h2c, out) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
606 out->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
607 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
608 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
609 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
610 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
611 "http2 frame sent: %p sid:%ui bl:%d len:%uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
612 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
613 out->blocked, out->length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
614 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
615 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
616 frame = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
617 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
618 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
619 fn = out->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
620 out->next = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
621 frame = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
622 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
623 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
624 h2c->last_out = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
625 |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
626 if (!wev->ready) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
627 ngx_add_timer(wev, clcf->send_timeout); |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
628 return NGX_AGAIN; |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
629 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
630 |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
631 if (wev->timer_set) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
632 ngx_del_timer(wev); |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
633 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
634 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
635 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
636 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
637 error: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
638 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
639 c->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
640 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
641 if (!h2c->blocked) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
642 ngx_post_event(wev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
643 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
644 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
645 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
646 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
647 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
648 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
649 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
650 ngx_http_v2_handle_connection(ngx_http_v2_connection_t *h2c) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
651 { |
7771
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
652 ngx_int_t rc; |
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
653 ngx_connection_t *c; |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
654 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
655 |
7201 | 656 if (h2c->last_out || h2c->processing || h2c->pushing) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
657 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
658 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
659 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
660 c = h2c->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
661 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
662 if (c->error) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
663 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
664 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
665 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
666 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
667 if (c->buffered) { |
6642
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
668 h2c->blocked = 1; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
669 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
670 rc = ngx_http_v2_send_output_queue(h2c); |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
671 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
672 h2c->blocked = 0; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
673 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
674 if (rc == NGX_ERROR) { |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
675 ngx_http_close_connection(c); |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
676 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
677 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
678 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
679 if (rc == NGX_AGAIN) { |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
680 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
681 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
682 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
683 /* rc == NGX_OK */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
684 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
685 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
686 if (h2c->goaway) { |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
687 ngx_http_v2_lingering_close(c); |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
688 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
689 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
690 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
691 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
692 ngx_http_core_module); |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
693 |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
694 if (!c->read->timer_set) { |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
695 ngx_add_timer(c->read, clcf->keepalive_timeout); |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
696 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
697 |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
698 ngx_reusable_connection(c, 1); |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
699 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
700 if (h2c->state.incomplete) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
701 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
702 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
703 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
704 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
705 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
706 h2c->pool = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
707 h2c->free_frames = NULL; |
7377 | 708 h2c->frames = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
709 h2c->free_fake_connections = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
710 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
711 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
712 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
713 ngx_ssl_free_buffer(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
714 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
715 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
716 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
717 c->destroyed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
718 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
719 c->write->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
720 c->read->handler = ngx_http_v2_idle_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
721 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
722 if (c->write->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
723 ngx_del_timer(c->write); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
724 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
725 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
726 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
727 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
728 static void |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
729 ngx_http_v2_lingering_close(ngx_connection_t *c) |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
730 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
731 ngx_event_t *rev, *wev; |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
732 ngx_http_v2_connection_t *h2c; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
733 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
734 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
735 h2c = c->data; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
736 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
737 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
738 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
739 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
740 if (clcf->lingering_close == NGX_HTTP_LINGERING_OFF) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
741 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
742 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
743 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
744 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
745 if (h2c->lingering_time == 0) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
746 h2c->lingering_time = ngx_time() |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
747 + (time_t) (clcf->lingering_time / 1000); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
748 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
749 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
750 #if (NGX_HTTP_SSL) |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
751 if (c->ssl) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
752 ngx_int_t rc; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
753 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
754 rc = ngx_ssl_shutdown(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
755 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
756 if (rc == NGX_ERROR) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
757 ngx_http_close_connection(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
758 return; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
759 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
760 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
761 if (rc == NGX_AGAIN) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
762 c->ssl->handler = ngx_http_v2_lingering_close; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
763 return; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
764 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
765 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
766 #endif |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
767 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
768 rev = c->read; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
769 rev->handler = ngx_http_v2_lingering_close_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
770 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
771 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
772 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
773 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
774 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
775 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
776 wev = c->write; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
777 wev->handler = ngx_http_empty_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
778 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
779 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
780 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
781 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
782 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
783 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
784 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
785 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
786 if (ngx_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
787 ngx_connection_error(c, ngx_socket_errno, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
788 ngx_shutdown_socket_n " failed"); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
789 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
790 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
791 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
792 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
793 c->close = 0; |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
794 ngx_reusable_connection(c, 1); |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
795 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
796 ngx_add_timer(rev, clcf->lingering_timeout); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
797 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
798 if (rev->ready) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
799 ngx_http_v2_lingering_close_handler(rev); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
800 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
801 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
802 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
803 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
804 static void |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
805 ngx_http_v2_lingering_close_handler(ngx_event_t *rev) |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
806 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
807 ssize_t n; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
808 ngx_msec_t timer; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
809 ngx_connection_t *c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
810 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
811 ngx_http_v2_connection_t *h2c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
812 u_char buffer[NGX_HTTP_LINGERING_BUFFER_SIZE]; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
813 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
814 c = rev->data; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
815 h2c = c->data; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
816 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
817 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
818 "http2 lingering close handler"); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
819 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
820 if (rev->timedout || c->close) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
821 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
822 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
823 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
824 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
825 timer = (ngx_msec_t) h2c->lingering_time - (ngx_msec_t) ngx_time(); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
826 if ((ngx_msec_int_t) timer <= 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
827 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
828 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
829 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
830 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
831 do { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
832 n = c->recv(c, buffer, NGX_HTTP_LINGERING_BUFFER_SIZE); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
833 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
834 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %z", n); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
835 |
7765
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
836 if (n == NGX_AGAIN) { |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
837 break; |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
838 } |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
839 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
840 if (n == NGX_ERROR || n == 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
841 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
842 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
843 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
844 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
845 } while (rev->ready); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
846 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
847 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
848 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
849 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
850 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
851 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
852 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
853 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
854 timer *= 1000; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
855 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
856 if (timer > clcf->lingering_timeout) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
857 timer = clcf->lingering_timeout; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
858 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
859 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
860 ngx_add_timer(rev, timer); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
861 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
862 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
863 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
864 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
865 ngx_http_v2_state_preface(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
866 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
867 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
868 static const u_char preface[] = NGX_HTTP_V2_PREFACE_START; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
869 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
870 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
871 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_preface); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
872 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
873 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
874 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) { |
7656
7114d21bc2b1
HTTP/2: invalid connection preface logging (ticket #1981).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7623
diff
changeset
|
875 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
7114d21bc2b1
HTTP/2: invalid connection preface logging (ticket #1981).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7623
diff
changeset
|
876 "invalid connection preface"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
877 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
878 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
879 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
880 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
881 return ngx_http_v2_state_preface_end(h2c, pos + sizeof(preface) - 1, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
882 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
883 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
884 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
885 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
886 ngx_http_v2_state_preface_end(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
887 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
888 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
889 static const u_char preface[] = NGX_HTTP_V2_PREFACE_END; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
890 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
891 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
892 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
893 ngx_http_v2_state_preface_end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
894 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
895 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
896 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) { |
7656
7114d21bc2b1
HTTP/2: invalid connection preface logging (ticket #1981).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7623
diff
changeset
|
897 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
7114d21bc2b1
HTTP/2: invalid connection preface logging (ticket #1981).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7623
diff
changeset
|
898 "invalid connection preface"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
899 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
900 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
901 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
902 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
903 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
904 "http2 preface verified"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
905 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
906 return ngx_http_v2_state_head(h2c, pos + sizeof(preface) - 1, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
907 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
908 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
909 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
910 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
911 ngx_http_v2_state_head(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
912 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
913 uint32_t head; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 ngx_uint_t type; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
915 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
916 if (end - pos < NGX_HTTP_V2_FRAME_HEADER_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
917 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_head); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
918 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
920 head = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
921 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
922 h2c->state.length = ngx_http_v2_parse_length(head); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
923 h2c->state.flags = pos[4]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
924 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
925 h2c->state.sid = ngx_http_v2_parse_sid(&pos[5]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
926 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
927 pos += NGX_HTTP_V2_FRAME_HEADER_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
928 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
929 type = ngx_http_v2_parse_type(head); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
930 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
931 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
7108
2bf605c6edf7
HTTP/2: shortened some debug log messages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7106
diff
changeset
|
932 "http2 frame type:%ui f:%Xd l:%uz sid:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
933 type, h2c->state.flags, h2c->state.length, h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
934 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
935 if (type >= NGX_HTTP_V2_FRAME_STATES) { |
7225
e80930e5e422
HTTP/2: unknown frames now logged at info level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7216
diff
changeset
|
936 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
e80930e5e422
HTTP/2: unknown frames now logged at info level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7216
diff
changeset
|
937 "client sent frame with unknown type %ui", type); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
938 return ngx_http_v2_state_skip(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
939 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
940 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
941 return ngx_http_v2_frame_states[type](h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
942 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
943 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
944 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
945 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
946 ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
947 { |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
948 size_t size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
949 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
950 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
951 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
952 size = h2c->state.length; |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
953 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
954 if (h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
955 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
956 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
957 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
958 "client sent padded DATA frame " |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
959 "with incorrect length: 0"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
960 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
961 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
962 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
963 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
964 if (end - pos == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
965 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
966 ngx_http_v2_state_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
967 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
968 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
969 h2c->state.padding = *pos++; |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
970 |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
971 if (h2c->state.padding >= size) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
972 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
973 "client sent padded DATA frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
974 "with incorrect length: %uz, padding: %uz", |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
975 size, h2c->state.padding); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
976 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
977 return ngx_http_v2_connection_error(h2c, |
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
978 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
979 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
980 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
981 h2c->state.length -= 1 + h2c->state.padding; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
982 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
983 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
984 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
985 "http2 DATA frame"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
986 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
987 if (h2c->state.sid == 0) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
988 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
989 "client sent DATA frame with incorrect identifier"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
990 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
991 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
992 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
993 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
994 if (size > h2c->recv_window) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
995 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
996 "client violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
997 "received DATA frame length %uz, available window %uz", |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
998 size, h2c->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
999 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1000 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_FLOW_CTRL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1001 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1002 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1003 h2c->recv_window -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1004 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1005 if (h2c->recv_window < NGX_HTTP_V2_MAX_WINDOW / 4) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1006 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1007 if (ngx_http_v2_send_window_update(h2c, 0, NGX_HTTP_V2_MAX_WINDOW |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1008 - h2c->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1009 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1010 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1011 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1012 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1013 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1014 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1016 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1017 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1018 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1019 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1020 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1021 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1022 "unknown http2 stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1023 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1024 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1025 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1026 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1028 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1029 if (size > stream->recv_window) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1030 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1031 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1032 "received DATA frame length %uz, available window %uz", |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1033 node->id, size, stream->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1034 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1035 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1037 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1038 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1039 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1040 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1041 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1042 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1043 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1044 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1045 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1046 stream->recv_window -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1048 if (stream->no_flow_control |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1049 && stream->recv_window < NGX_HTTP_V2_MAX_WINDOW / 4) |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1050 { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1051 if (ngx_http_v2_send_window_update(h2c, node->id, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1052 NGX_HTTP_V2_MAX_WINDOW |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1053 - stream->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1054 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1055 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1056 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1057 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1058 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1059 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1060 stream->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1061 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1062 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1063 if (stream->in_closed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1064 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1065 "client sent DATA frame for half-closed stream %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1066 node->id); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1067 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1068 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1069 NGX_HTTP_V2_STREAM_CLOSED) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1071 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1072 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1073 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1074 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1076 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1077 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1078 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1079 h2c->state.stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1080 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1081 return ngx_http_v2_state_read_data(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1082 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1083 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1084 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1085 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1086 ngx_http_v2_state_read_data(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1087 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1088 { |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
1089 size_t size; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1090 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1091 ngx_int_t rc; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1092 ngx_connection_t *fc; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1093 ngx_http_request_t *r; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1094 ngx_http_v2_stream_t *stream; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1095 ngx_http_v2_srv_conf_t *h2scf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1096 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1097 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1098 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1099 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1100 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1101 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1102 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1103 if (stream->skip_data) { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1104 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1105 "skipping http2 DATA frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1106 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1107 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1108 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1109 |
7561
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1110 r = stream->request; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1111 fc = r->connection; |
7561
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1112 |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1113 if (r->reading_body && !r->request_body_no_buffering) { |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1114 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1115 "skipping http2 DATA frame"); |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1116 |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1117 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1118 } |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1119 |
7710
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1120 if (r->headers_in.content_length_n < 0 && !r->headers_in.chunked) { |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1121 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1122 "skipping http2 DATA frame"); |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1123 |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1124 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1125 } |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1126 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1127 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1128 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1129 if (size >= h2c->state.length) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1130 size = h2c->state.length; |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
1131 stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1132 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1133 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1134 h2c->payload_bytes += size; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1135 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1136 if (r->request_body) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1137 rc = ngx_http_v2_process_request_body(r, pos, size, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1138 stream->in_closed, 0); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1139 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1140 if (rc != NGX_OK && rc != NGX_AGAIN) { |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1141 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1142 ngx_http_finalize_request(r, rc); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1143 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1144 |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1145 ngx_http_run_posted_requests(fc); |
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1146 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1147 } else if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1148 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1149 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1150 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1151 h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1152 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1153 buf = ngx_create_temp_buf(r->pool, h2scf->preread_size); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1154 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1155 return ngx_http_v2_connection_error(h2c, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1156 NGX_HTTP_V2_INTERNAL_ERROR); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1157 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1158 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1159 stream->preread = buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1160 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1161 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1162 if (size > (size_t) (buf->end - buf->last)) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1163 ngx_log_error(NGX_LOG_ALERT, h2c->connection->log, 0, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1164 "http2 preread buffer overflow"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1165 return ngx_http_v2_connection_error(h2c, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1166 NGX_HTTP_V2_INTERNAL_ERROR); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1167 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1168 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1169 buf->last = ngx_cpymem(buf->last, pos, size); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1170 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1171 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1172 pos += size; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1173 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1174 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1175 if (h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1176 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1177 ngx_http_v2_state_read_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1178 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1179 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1180 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1181 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1182 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1183 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1184 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1185 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1186 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1187 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1188 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1189 ngx_http_v2_state_headers(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1190 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1191 { |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1192 size_t size; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1193 ngx_uint_t padded, priority, depend, dependency, excl, |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1194 weight; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1195 ngx_uint_t status; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1196 ngx_http_v2_node_t *node; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1197 ngx_http_v2_stream_t *stream; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1198 ngx_http_v2_srv_conf_t *h2scf; |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1199 ngx_http_core_srv_conf_t *cscf; |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1200 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1201 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1202 padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1203 priority = h2c->state.flags & NGX_HTTP_V2_PRIORITY_FLAG; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1204 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1205 size = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1206 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1207 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1208 size++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1209 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1210 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1211 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1212 size += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1213 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1214 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1215 if (h2c->state.length < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1216 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1217 "client sent HEADERS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1218 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1219 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1220 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1221 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1222 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1223 if (h2c->state.length == size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1224 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1225 "client sent HEADERS frame with empty header block"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1226 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1227 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1228 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1229 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1230 if (h2c->goaway) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1231 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1232 "skipping http2 HEADERS frame"); |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1233 return ngx_http_v2_state_skip(h2c, pos, end); |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1234 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1235 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1236 if ((size_t) (end - pos) < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1237 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1238 ngx_http_v2_state_headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1239 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1240 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1241 h2c->state.length -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1242 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1243 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1244 h2c->state.padding = *pos++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1245 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1246 if (h2c->state.padding > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1247 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1248 "client sent padded HEADERS frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1249 "with incorrect length: %uz, padding: %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1250 h2c->state.length, h2c->state.padding); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1251 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
1252 return ngx_http_v2_connection_error(h2c, |
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
1253 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1254 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1255 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1256 h2c->state.length -= h2c->state.padding; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1257 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1258 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1259 depend = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1260 excl = 0; |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1261 weight = NGX_HTTP_V2_DEFAULT_WEIGHT; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1262 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1263 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1264 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1265 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1266 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1267 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1268 weight = pos[4] + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1269 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1270 pos += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1271 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1272 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1273 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1274 "http2 HEADERS frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1275 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1276 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1277 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1278 if (h2c->state.sid % 2 == 0 || h2c->state.sid <= h2c->last_sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1279 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1280 "client sent HEADERS frame with incorrect identifier " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1281 "%ui, the last was %ui", h2c->state.sid, h2c->last_sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1282 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1283 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1284 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1285 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1286 if (depend == h2c->state.sid) { |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1287 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1288 "client sent HEADERS frame for stream %ui " |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1289 "with incorrect dependency", h2c->state.sid); |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1290 |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1291 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1292 } |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1293 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1294 h2c->last_sid = h2c->state.sid; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1295 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1296 h2c->state.pool = ngx_create_pool(1024, h2c->connection->log); |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1297 if (h2c->state.pool == NULL) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1298 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1299 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1300 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1301 cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1302 ngx_http_core_module); |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1303 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1304 h2c->state.header_limit = cscf->large_client_header_buffers.size |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1305 * cscf->large_client_header_buffers.num; |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1306 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1307 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1308 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1309 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1310 if (h2c->processing >= h2scf->concurrent_streams) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1311 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1312 "concurrent streams exceeded %ui", h2c->processing); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1313 |
6513
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1314 status = NGX_HTTP_V2_REFUSED_STREAM; |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1315 goto rst_stream; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1316 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1317 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1318 if (!h2c->settings_ack |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1319 && !(h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG) |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1320 && h2scf->preread_size < NGX_HTTP_V2_DEFAULT_WINDOW) |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1321 { |
6516
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1322 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1323 "client sent stream with data " |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1324 "before settings were acknowledged"); |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1325 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1326 status = NGX_HTTP_V2_REFUSED_STREAM; |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1327 goto rst_stream; |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1328 } |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1329 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1330 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1331 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1332 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1333 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1334 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1335 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1336 if (node->parent) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1337 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1338 h2c->closed_nodes--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1339 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1340 |
7201 | 1341 stream = ngx_http_v2_create_stream(h2c, 0); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1342 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1343 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1344 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1345 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1346 h2c->state.stream = stream; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1347 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1348 stream->pool = h2c->state.pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1349 h2c->state.keep_pool = 1; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1350 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1351 stream->request->request_length = h2c->state.length; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1352 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1353 stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1354 stream->node = node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1355 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1356 node->stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1357 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1358 if (priority || node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1359 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1360 ngx_http_v2_set_dependency(h2c, node, depend, excl); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1361 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1362 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1363 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1364 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1365 |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1366 if (clcf->keepalive_timeout == 0 |
7820
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1367 || h2c->connection->requests >= clcf->keepalive_requests |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1368 || ngx_current_msec - h2c->connection->start_time |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1369 > clcf->keepalive_time) |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1370 { |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1371 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1372 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1373 if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) == NGX_ERROR) { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1374 return ngx_http_v2_connection_error(h2c, |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1375 NGX_HTTP_V2_INTERNAL_ERROR); |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1376 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1377 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1378 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1379 return ngx_http_v2_state_header_block(h2c, pos, end); |
6513
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1380 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1381 rst_stream: |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1382 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1383 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, status) != NGX_OK) { |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1384 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1385 } |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1386 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1387 return ngx_http_v2_state_header_block(h2c, pos, end); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1388 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1389 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1390 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1391 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1392 ngx_http_v2_state_header_block(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1393 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1394 { |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1395 u_char ch; |
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1396 ngx_int_t value; |
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1397 ngx_uint_t indexed, size_update, prefix; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1398 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1399 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1400 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1401 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1402 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1403 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1404 if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1405 && h2c->state.length < NGX_HTTP_V2_INT_OCTETS) |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1406 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1407 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1408 ngx_http_v2_state_header_block); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1409 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1410 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1411 size_update = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1412 indexed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1413 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1414 ch = *pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1415 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1416 if (ch >= (1 << 7)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1417 /* indexed header field */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1418 indexed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1419 prefix = ngx_http_v2_prefix(7); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1420 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1421 } else if (ch >= (1 << 6)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1422 /* literal header field with incremental indexing */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1423 h2c->state.index = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1424 prefix = ngx_http_v2_prefix(6); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1425 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1426 } else if (ch >= (1 << 5)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1427 /* dynamic table size update */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1428 size_update = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1429 prefix = ngx_http_v2_prefix(5); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1430 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1431 } else if (ch >= (1 << 4)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1432 /* literal header field never indexed */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1433 prefix = ngx_http_v2_prefix(4); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1434 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1435 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1436 /* literal header field without indexing */ |
6260
0e37389c0bd5
HTTP/2: fixed parsing of literal header fields without indexing.
Valentin Bartenev <vbart@nginx.com>
parents:
6256
diff
changeset
|
1437 prefix = ngx_http_v2_prefix(4); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1438 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1439 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1440 value = ngx_http_v2_parse_int(h2c, &pos, end, prefix); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1441 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1442 if (value < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1443 if (value == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1444 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1445 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1446 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1447 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1448 if (value == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1449 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1450 "client sent header block with too long %s value", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1451 size_update ? "size update" : "header index"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1452 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1453 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1454 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1455 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1456 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1457 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1458 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1459 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1460 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1461 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1462 if (indexed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1463 if (ngx_http_v2_get_indexed_header(h2c, value, 0) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1464 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1465 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1466 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1467 return ngx_http_v2_state_process_header(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1468 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1469 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1470 if (size_update) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1471 if (ngx_http_v2_table_size(h2c, value) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1472 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1473 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1474 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1475 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1476 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1477 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1478 if (value == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1479 h2c->state.parse_name = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1480 |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1481 } else if (ngx_http_v2_get_indexed_header(h2c, value, 1) != NGX_OK) { |
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1482 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1483 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1484 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1485 h2c->state.parse_value = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1486 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1487 return ngx_http_v2_state_field_len(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1488 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1489 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1490 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1491 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1492 ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1493 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1494 { |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1495 size_t alloc; |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1496 ngx_int_t len; |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1497 ngx_uint_t huff; |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1498 ngx_http_core_srv_conf_t *cscf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1499 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1500 if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1501 && h2c->state.length < NGX_HTTP_V2_INT_OCTETS) |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1502 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1503 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1504 ngx_http_v2_state_field_len); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1505 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1506 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1507 if (h2c->state.length < 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1508 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1509 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1510 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1511 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1512 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1513 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1514 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1515 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1516 ngx_http_v2_state_field_len); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1517 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1518 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1519 huff = *pos >> 7; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1520 len = ngx_http_v2_parse_int(h2c, &pos, end, ngx_http_v2_prefix(7)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1521 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1522 if (len < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1523 if (len == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1524 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1525 ngx_http_v2_state_field_len); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1526 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1527 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1528 if (len == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1529 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1530 "client sent header field with too long length value"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1531 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1532 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1533 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1534 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1535 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1536 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1537 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1538 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1539 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1540 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1541 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
7108
2bf605c6edf7
HTTP/2: shortened some debug log messages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7106
diff
changeset
|
1542 "http2 %s string, len:%i", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1543 huff ? "encoded" : "raw", len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1544 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1545 cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1546 ngx_http_core_module); |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1547 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1548 if ((size_t) len > cscf->large_client_header_buffers.size) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1549 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1550 "client sent too large header field"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1551 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1552 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1553 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1554 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1555 h2c->state.field_rest = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1556 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1557 if (h2c->state.stream == NULL && !h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1558 return ngx_http_v2_state_field_skip(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1559 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1560 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1561 alloc = (huff ? len * 8 / 5 : len) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1562 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1563 h2c->state.field_start = ngx_pnalloc(h2c->state.pool, alloc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1564 if (h2c->state.field_start == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1565 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1566 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1567 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1568 h2c->state.field_end = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1569 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1570 if (huff) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1571 return ngx_http_v2_state_field_huff(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1572 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1573 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1574 return ngx_http_v2_state_field_raw(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1575 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1576 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1577 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1578 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1579 ngx_http_v2_state_field_huff(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1580 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1581 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1582 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1583 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1584 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1585 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1586 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1587 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1588 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1589 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1590 if (size > h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1591 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1592 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1593 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1594 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1595 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1596 |
7977
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1597 if (ngx_http_huff_decode(&h2c->state.field_state, pos, size, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1598 &h2c->state.field_end, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1599 h2c->state.field_rest == 0, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1600 h2c->connection->log) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1601 != NGX_OK) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1602 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1603 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1604 "client sent invalid encoded header field"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1605 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1606 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1607 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1608 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1609 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1610 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1611 if (h2c->state.field_rest == 0) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1612 *h2c->state.field_end = '\0'; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1613 return ngx_http_v2_state_process_header(h2c, pos, end); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1614 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1615 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1616 if (h2c->state.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1617 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1618 ngx_http_v2_state_field_huff); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1619 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1620 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1621 if (h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1622 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1623 "client sent header field with incorrect length"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1624 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1625 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1626 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1627 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1628 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1629 ngx_http_v2_state_field_huff); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1630 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1631 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1632 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1633 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1634 ngx_http_v2_state_field_raw(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1635 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1636 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1637 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1638 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1639 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1640 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1641 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1642 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1643 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1644 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1645 if (size > h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1646 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1647 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1648 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1649 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1650 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1651 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1652 h2c->state.field_end = ngx_cpymem(h2c->state.field_end, pos, size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1653 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1654 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1655 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1656 if (h2c->state.field_rest == 0) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1657 *h2c->state.field_end = '\0'; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1658 return ngx_http_v2_state_process_header(h2c, pos, end); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1659 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1660 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1661 if (h2c->state.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1662 return ngx_http_v2_state_headers_save(h2c, pos, end, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1663 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1664 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1665 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1666 if (h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1667 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1668 "client sent header field with incorrect length"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1669 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1670 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1671 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1672 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1673 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1674 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1675 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1676 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1677 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1678 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1679 ngx_http_v2_state_field_skip(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1680 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1681 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1682 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1683 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1684 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1685 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1686 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1687 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1688 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1689 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1690 if (size > h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1691 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1692 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1693 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1694 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1695 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1696 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1697 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1698 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1699 if (h2c->state.field_rest == 0) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1700 return ngx_http_v2_state_process_header(h2c, pos, end); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1701 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1702 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1703 if (h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1704 return ngx_http_v2_state_save(h2c, pos, end, |
6248
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1705 ngx_http_v2_state_field_skip); |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1706 } |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1707 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1708 if (h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1709 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1710 "client sent header field with incorrect length"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1711 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1712 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1713 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1714 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1715 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1716 ngx_http_v2_state_field_skip); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1717 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1718 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1719 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1720 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1721 ngx_http_v2_state_process_header(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1722 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1723 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1724 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1725 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1726 ngx_table_elt_t *h; |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1727 ngx_connection_t *fc; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1728 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1729 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1730 ngx_http_v2_header_t *header; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1731 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1732 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1733 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1734 static ngx_str_t cookie = ngx_string("cookie"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1735 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1736 header = &h2c->state.header; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1737 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1738 if (h2c->state.parse_name) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1739 h2c->state.parse_name = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1740 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1741 header->name.len = h2c->state.field_end - h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1742 header->name.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1743 |
7547
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1744 if (header->name.len == 0) { |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1745 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1746 "client sent zero header name length"); |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1747 |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1748 return ngx_http_v2_connection_error(h2c, |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1749 NGX_HTTP_V2_PROTOCOL_ERROR); |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1750 } |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1751 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1752 return ngx_http_v2_state_field_len(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1753 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1754 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1755 if (h2c->state.parse_value) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1756 h2c->state.parse_value = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1757 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1758 header->value.len = h2c->state.field_end - h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1759 header->value.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1760 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1761 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1762 len = header->name.len + header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1763 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1764 if (len > h2c->state.header_limit) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1765 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1766 "client sent too large header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1767 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1768 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1769 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1770 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1771 h2c->state.header_limit -= len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1772 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1773 if (h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1774 if (ngx_http_v2_add_header(h2c, header) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1775 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1776 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1777 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1778 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1779 h2c->state.index = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1780 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1781 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1782 if (h2c->state.stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1783 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1784 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1785 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1786 r = h2c->state.stream->request; |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1787 fc = r->connection; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1788 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1789 /* TODO Optimization: validate headers while parsing. */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1790 if (ngx_http_v2_validate_header(r, header) != NGX_OK) { |
8148
9db24374123b
HTTP/2: finalize request as bad if header validation fails.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8147
diff
changeset
|
1791 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1792 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1793 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1794 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1795 if (header->name.data[0] == ':') { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1796 rc = ngx_http_v2_pseudo_header(r, header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1797 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1798 if (rc == NGX_OK) { |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1799 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7108
2bf605c6edf7
HTTP/2: shortened some debug log messages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7106
diff
changeset
|
1800 "http2 header: \":%V: %V\"", |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1801 &header->name, &header->value); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1802 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1803 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1804 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1805 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1806 if (rc == NGX_ABORT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1807 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1808 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1809 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1810 if (rc == NGX_DECLINED) { |
7192
d5a535774861
HTTP/2: finalize request as bad if parsing of pseudo-headers fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7191
diff
changeset
|
1811 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1812 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1813 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1814 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1815 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1816 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1817 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1818 if (r->invalid_header) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1819 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1820 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1821 if (cscf->ignore_invalid_headers) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1822 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1823 "client sent invalid header: \"%V\"", &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1824 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1825 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1826 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1827 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1828 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1829 if (header->name.len == cookie.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1830 && ngx_memcmp(header->name.data, cookie.data, cookie.len) == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1831 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1832 if (ngx_http_v2_cookie(r, header) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1833 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1834 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1835 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1836 |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1837 } else { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1838 h = ngx_list_push(&r->headers_in.headers); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1839 if (h == NULL) { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1840 return ngx_http_v2_connection_error(h2c, |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1841 NGX_HTTP_V2_INTERNAL_ERROR); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1842 } |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1843 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1844 h->key.len = header->name.len; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1845 h->key.data = header->name.data; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1846 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1847 /* |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1848 * TODO Optimization: precalculate hash |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1849 * and handler for indexed headers. |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1850 */ |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1851 h->hash = ngx_hash_key(h->key.data, h->key.len); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1852 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1853 h->value.len = header->value.len; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1854 h->value.data = header->value.data; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1855 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1856 h->lowcase_key = h->key.data; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1857 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1858 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1859 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1860 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1861 h->lowcase_key, h->key.len); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1862 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1863 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1864 goto error; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1865 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1866 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1867 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1868 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7108
2bf605c6edf7
HTTP/2: shortened some debug log messages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7106
diff
changeset
|
1869 "http2 header: \"%V: %V\"", |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1870 &header->name, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1871 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1872 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1873 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1874 error: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1875 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1876 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1877 |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1878 ngx_http_run_posted_requests(fc); |
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1879 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1880 return ngx_http_v2_state_header_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1881 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1882 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1883 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1884 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1885 ngx_http_v2_state_header_complete(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1886 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1887 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1888 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1889 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1890 if (h2c->state.length) { |
7623
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1891 if (end - pos > 0) { |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1892 h2c->state.handler = ngx_http_v2_state_header_block; |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1893 return pos; |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1894 } |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1895 |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1896 return ngx_http_v2_state_headers_save(h2c, pos, end, |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1897 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1898 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1899 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1900 if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG)) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1901 return ngx_http_v2_handle_continuation(h2c, pos, end, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1902 ngx_http_v2_state_header_complete); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1903 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1904 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1905 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1906 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1907 if (stream) { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1908 ngx_http_v2_run_request(stream->request); |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1909 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1910 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1911 if (!h2c->state.keep_pool) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1912 ngx_destroy_pool(h2c->state.pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1913 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1914 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1915 h2c->state.pool = NULL; |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1916 h2c->state.keep_pool = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1917 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1918 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1919 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1920 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1921 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1922 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1923 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1924 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1925 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1926 static u_char * |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1927 ngx_http_v2_handle_continuation(ngx_http_v2_connection_t *h2c, u_char *pos, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1928 u_char *end, ngx_http_v2_handler_pt handler) |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1929 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1930 u_char *p; |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1931 size_t len, skip; |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1932 uint32_t head; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1933 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1934 len = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1935 |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1936 if (h2c->state.padding && (size_t) (end - pos) > len) { |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1937 skip = ngx_min(h2c->state.padding, (end - pos) - len); |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1938 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1939 h2c->state.padding -= skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1940 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1941 p = pos; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1942 pos += skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1943 ngx_memmove(pos, p, len); |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1944 } |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1945 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1946 if ((size_t) (end - pos) < len + NGX_HTTP_V2_FRAME_HEADER_SIZE) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1947 return ngx_http_v2_state_headers_save(h2c, pos, end, handler); |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1948 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1949 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1950 p = pos + len; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1951 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1952 head = ngx_http_v2_parse_uint32(p); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1953 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1954 if (ngx_http_v2_parse_type(head) != NGX_HTTP_V2_CONTINUATION_FRAME) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1955 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1956 "client sent inappropriate frame while CONTINUATION was expected"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1957 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1958 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1959 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1960 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1961 h2c->state.flags |= p[4]; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1962 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1963 if (h2c->state.sid != ngx_http_v2_parse_sid(&p[5])) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1964 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1965 "client sent CONTINUATION frame with incorrect identifier"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1966 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1967 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1968 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1969 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1970 p = pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1971 pos += NGX_HTTP_V2_FRAME_HEADER_SIZE; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1972 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1973 ngx_memcpy(pos, p, len); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1974 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1975 len = ngx_http_v2_parse_length(head); |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1976 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1977 h2c->state.length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1978 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1979 if (h2c->state.stream) { |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1980 h2c->state.stream->request->request_length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1981 } |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1982 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1983 h2c->state.handler = handler; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1984 return pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1985 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1986 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1987 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1988 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1989 ngx_http_v2_state_priority(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1990 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1991 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1992 ngx_uint_t depend, dependency, excl, weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1993 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1994 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1995 if (h2c->state.length != NGX_HTTP_V2_PRIORITY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1996 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1997 "client sent PRIORITY frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1998 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1999 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2000 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2001 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2002 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2003 if (--h2c->priority_limit == 0) { |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2004 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2005 "client sent too many PRIORITY frames"); |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2006 |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2007 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM); |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2008 } |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2009 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2010 if (end - pos < NGX_HTTP_V2_PRIORITY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2011 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2012 ngx_http_v2_state_priority); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2013 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2014 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2015 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2016 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2017 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2018 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2019 weight = pos[4] + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2020 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2021 pos += NGX_HTTP_V2_PRIORITY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2022 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2023 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2024 "http2 PRIORITY frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2025 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2026 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2027 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2028 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2029 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2030 "client sent PRIORITY frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2031 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2032 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2033 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2034 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2035 if (depend == h2c->state.sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2036 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2037 "client sent PRIORITY frame for stream %ui " |
6284
66ee1c5cb6aa
HTTP/2: fixed spelling.
Valentin Bartenev <vbart@nginx.com>
parents:
6280
diff
changeset
|
2038 "with incorrect dependency", h2c->state.sid); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2039 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
2040 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2041 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2042 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2043 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2044 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2045 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2046 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2047 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2048 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2049 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2050 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2051 if (node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2052 if (node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2053 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2054 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2055 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2056 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2057 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2058 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2059 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2060 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2061 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2062 ngx_http_v2_set_dependency(h2c, node, depend, excl); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2063 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2064 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2065 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2066 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2067 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2068 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2069 ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2070 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2071 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2072 ngx_uint_t status; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2073 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2074 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2075 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2076 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2077 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2078 if (h2c->state.length != NGX_HTTP_V2_RST_STREAM_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2079 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2080 "client sent RST_STREAM frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2081 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2082 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2083 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2084 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2085 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2086 if (end - pos < NGX_HTTP_V2_RST_STREAM_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2087 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2088 ngx_http_v2_state_rst_stream); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2089 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2090 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2091 status = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2092 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2093 pos += NGX_HTTP_V2_RST_STREAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2094 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2095 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2096 "http2 RST_STREAM frame, sid:%ui status:%ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2097 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2098 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2099 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2100 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2101 "client sent RST_STREAM frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2102 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2103 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2104 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2105 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2106 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2107 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2108 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2109 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
2110 "unknown http2 stream"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2111 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2112 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2113 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2114 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2115 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2116 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2117 stream->in_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2118 stream->out_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2119 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2120 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2121 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2122 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2123 switch (status) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2124 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2125 case NGX_HTTP_V2_CANCEL: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2126 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2127 "client canceled stream %ui", h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2128 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2129 |
7201 | 2130 case NGX_HTTP_V2_REFUSED_STREAM: |
2131 ngx_log_error(NGX_LOG_INFO, fc->log, 0, | |
2132 "client refused stream %ui", h2c->state.sid); | |
2133 break; | |
2134 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2135 case NGX_HTTP_V2_INTERNAL_ERROR: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2136 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2137 "client terminated stream %ui due to internal error", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2138 h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2139 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2140 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2141 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2142 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2143 "client terminated stream %ui with status %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2144 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2145 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2146 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2147 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2148 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2149 ev->handler(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2150 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2151 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2152 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2153 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2154 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2155 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2156 ngx_http_v2_state_settings(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2157 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2158 { |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2159 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2160 "http2 SETTINGS frame"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2161 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2162 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2163 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2164 "client sent SETTINGS frame with incorrect identifier"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2165 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2166 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2167 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2168 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2169 if (h2c->state.flags == NGX_HTTP_V2_ACK_FLAG) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2170 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2171 if (h2c->state.length != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2172 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2173 "client sent SETTINGS frame with the ACK flag " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2174 "and nonzero length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2175 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2176 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2177 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2178 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
2179 h2c->settings_ack = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2180 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2181 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2182 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2183 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2184 if (h2c->state.length % NGX_HTTP_V2_SETTINGS_PARAM_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2185 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2186 "client sent SETTINGS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2187 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2188 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2189 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2190 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2191 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2192 return ngx_http_v2_state_settings_params(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2193 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2194 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2195 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2196 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2197 ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2198 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2199 { |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2200 ssize_t window_delta; |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2201 ngx_uint_t id, value; |
7201 | 2202 ngx_http_v2_srv_conf_t *h2scf; |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2203 ngx_http_v2_out_frame_t *frame; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2204 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2205 window_delta = 0; |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2206 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2207 while (h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2208 if (end - pos < NGX_HTTP_V2_SETTINGS_PARAM_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2209 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2210 ngx_http_v2_state_settings_params); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2211 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2212 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2213 h2c->state.length -= NGX_HTTP_V2_SETTINGS_PARAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2214 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2215 id = ngx_http_v2_parse_uint16(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2216 value = ngx_http_v2_parse_uint32(&pos[2]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2217 |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2218 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2219 "http2 setting %ui:%ui", id, value); |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2220 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2221 switch (id) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2222 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2223 case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2224 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2225 if (value > NGX_HTTP_V2_MAX_WINDOW) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2226 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2227 "client sent SETTINGS frame with incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2228 "INITIAL_WINDOW_SIZE value %ui", value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2229 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2230 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2231 NGX_HTTP_V2_FLOW_CTRL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2232 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2233 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2234 window_delta = value - h2c->init_window; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2235 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2236 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2237 case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING: |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
2238 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2239 if (value > NGX_HTTP_V2_MAX_FRAME_SIZE |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2240 || value < NGX_HTTP_V2_DEFAULT_FRAME_SIZE) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2241 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2242 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2243 "client sent SETTINGS frame with incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2244 "MAX_FRAME_SIZE value %ui", value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2245 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2246 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2247 NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2248 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2249 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2250 h2c->frame_size = value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2251 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2252 |
7201 | 2253 case NGX_HTTP_V2_ENABLE_PUSH_SETTING: |
2254 | |
2255 if (value > 1) { | |
2256 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
2257 "client sent SETTINGS frame with incorrect " | |
2258 "ENABLE_PUSH value %ui", value); | |
2259 | |
2260 return ngx_http_v2_connection_error(h2c, | |
2261 NGX_HTTP_V2_PROTOCOL_ERROR); | |
2262 } | |
2263 | |
2264 h2c->push_disabled = !value; | |
2265 break; | |
2266 | |
2267 case NGX_HTTP_V2_MAX_STREAMS_SETTING: | |
2268 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, | |
2269 ngx_http_v2_module); | |
2270 | |
2271 h2c->concurrent_pushes = ngx_min(value, h2scf->concurrent_pushes); | |
2272 break; | |
2273 | |
7335
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2274 case NGX_HTTP_V2_HEADER_TABLE_SIZE_SETTING: |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2275 |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2276 h2c->table_update = 1; |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2277 break; |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2278 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2279 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2280 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2281 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2282 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2283 pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2284 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2285 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2286 frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_SETTINGS_ACK_SIZE, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2287 NGX_HTTP_V2_SETTINGS_FRAME, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2288 NGX_HTTP_V2_ACK_FLAG, 0); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2289 if (frame == NULL) { |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2290 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2291 } |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2292 |
7025
7206c3630310
HTTP/2: don't send SETTINGS ACK before already queued DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
7024
diff
changeset
|
2293 ngx_http_v2_queue_ordered_frame(h2c, frame); |
7023
859d80f57aab
HTTP/2: send SETTINGS ACK after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7022
diff
changeset
|
2294 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2295 if (window_delta) { |
7190
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2296 h2c->init_window += window_delta; |
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2297 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2298 if (ngx_http_v2_adjust_windows(h2c, window_delta) != NGX_OK) { |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2299 return ngx_http_v2_connection_error(h2c, |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2300 NGX_HTTP_V2_INTERNAL_ERROR); |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2301 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2302 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2303 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2304 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2305 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2306 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2307 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2308 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2309 ngx_http_v2_state_push_promise(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2310 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2311 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2312 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2313 "client sent PUSH_PROMISE frame"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2314 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2315 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2316 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2317 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2318 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2319 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2320 ngx_http_v2_state_ping(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2321 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2322 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2323 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2324 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2325 if (h2c->state.length != NGX_HTTP_V2_PING_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2326 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2327 "client sent PING frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2328 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2329 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2330 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2331 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2332 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2333 if (end - pos < NGX_HTTP_V2_PING_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2334 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_ping); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2335 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2336 |
7241
190591ab0d76
HTTP/2: improved frame info debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7229
diff
changeset
|
2337 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
190591ab0d76
HTTP/2: improved frame info debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7229
diff
changeset
|
2338 "http2 PING frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2339 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2340 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2341 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2342 "client sent PING frame with incorrect identifier"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2343 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2344 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2345 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2346 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2347 if (h2c->state.flags & NGX_HTTP_V2_ACK_FLAG) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2348 return ngx_http_v2_state_skip(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2349 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2350 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2351 frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_PING_SIZE, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2352 NGX_HTTP_V2_PING_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2353 NGX_HTTP_V2_ACK_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2354 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2355 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2356 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2357 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2358 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2359 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2360 buf->last = ngx_cpymem(buf->last, pos, NGX_HTTP_V2_PING_SIZE); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2361 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2362 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2363 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2364 return ngx_http_v2_state_complete(h2c, pos + NGX_HTTP_V2_PING_SIZE, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2365 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2366 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2367 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2368 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2369 ngx_http_v2_state_goaway(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2370 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2371 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2372 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2373 ngx_uint_t last_sid, error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2374 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2375 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2376 if (h2c->state.length < NGX_HTTP_V2_GOAWAY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2377 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2378 "client sent GOAWAY frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2379 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2380 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2381 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2382 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2383 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2384 if (end - pos < NGX_HTTP_V2_GOAWAY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2385 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_goaway); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2386 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2387 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2388 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2389 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2390 "client sent GOAWAY frame with incorrect identifier"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2391 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2392 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2393 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2394 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2395 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2396 h2c->state.length -= NGX_HTTP_V2_GOAWAY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2397 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2398 last_sid = ngx_http_v2_parse_sid(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2399 error = ngx_http_v2_parse_uint32(&pos[4]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2400 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2401 pos += NGX_HTTP_V2_GOAWAY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2402 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2403 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2404 "http2 GOAWAY frame: last sid %ui, error %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2405 last_sid, error); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2406 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2407 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2408 return ngx_http_v2_state_skip(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2409 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2410 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2411 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2412 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2413 ngx_http_v2_state_window_update(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2414 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2415 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2416 size_t window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2417 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2418 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2419 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2420 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2421 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2422 if (h2c->state.length != NGX_HTTP_V2_WINDOW_UPDATE_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2423 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2424 "client sent WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2425 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2426 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2427 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2428 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2429 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2430 if (end - pos < NGX_HTTP_V2_WINDOW_UPDATE_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2431 return ngx_http_v2_state_save(h2c, pos, end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2432 ngx_http_v2_state_window_update); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2433 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2434 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2435 window = ngx_http_v2_parse_window(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2436 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2437 pos += NGX_HTTP_V2_WINDOW_UPDATE_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2438 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2439 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2440 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2441 h2c->state.sid, window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2442 |
6988
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2443 if (window == 0) { |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2444 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
7565
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2445 "client sent WINDOW_UPDATE frame " |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2446 "with incorrect window increment 0"); |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2447 |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2448 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
6988
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2449 } |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2450 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2451 if (h2c->state.sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2452 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2453 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2454 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2455 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2456 "unknown http2 stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2457 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2458 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2459 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2460 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2461 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2462 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2463 if (window > (size_t) (NGX_HTTP_V2_MAX_WINDOW - stream->send_window)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2464 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2465 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2466 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2467 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2468 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2469 "not allowed for window %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2470 h2c->state.sid, window, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2471 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2472 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2473 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2474 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2475 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2476 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2477 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2478 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2479 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2480 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2481 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2482 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2483 stream->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2484 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2485 if (stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2486 stream->exhausted = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2487 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2488 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2489 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2490 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2491 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2492 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2493 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2494 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2495 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2496 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2497 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2498 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2499 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2500 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2501 if (window > NGX_HTTP_V2_MAX_WINDOW - h2c->send_window) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2502 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2503 "client violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2504 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2505 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2506 "not allowed for window %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2507 window, h2c->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2508 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2509 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_FLOW_CTRL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2510 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2511 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2512 h2c->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2513 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2514 while (!ngx_queue_empty(&h2c->waiting)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2515 q = ngx_queue_head(&h2c->waiting); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2516 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2517 ngx_queue_remove(q); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2518 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2519 stream = ngx_queue_data(q, ngx_http_v2_stream_t, queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2520 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
2521 stream->waiting = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2522 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2523 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2524 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2525 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2526 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2527 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2528 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2529 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2530 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2531 if (h2c->send_window == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2532 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2533 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2534 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2535 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2536 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2537 return ngx_http_v2_state_complete(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2538 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2539 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2540 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2541 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2542 ngx_http_v2_state_continuation(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2543 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2544 { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2545 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2546 "client sent unexpected CONTINUATION frame"); |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2547 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2548 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2549 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2550 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2551 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2552 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2553 ngx_http_v2_state_complete(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2554 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2555 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2556 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2557 "http2 frame complete pos:%p end:%p", pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2558 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2559 if (pos > end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2560 ngx_log_error(NGX_LOG_ALERT, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2561 "receive buffer overrun"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2562 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2563 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2564 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2565 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2566 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2567 h2c->state.handler = ngx_http_v2_state_head; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2568 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2569 return pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2570 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2571 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2572 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2573 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2574 ngx_http_v2_state_skip_padded(ngx_http_v2_connection_t *h2c, u_char *pos, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2575 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2576 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2577 h2c->state.length += h2c->state.padding; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2578 h2c->state.padding = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2579 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2580 return ngx_http_v2_state_skip(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2581 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2582 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2583 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2584 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2585 ngx_http_v2_state_skip(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2586 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2587 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2588 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2589 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2590 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2591 if (size < h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2592 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2593 "http2 frame skip %uz of %uz", size, h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2594 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2595 h2c->state.length -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2596 return ngx_http_v2_state_save(h2c, end, end, ngx_http_v2_state_skip); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2597 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2598 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2599 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2600 "http2 frame skip %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2601 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2602 return ngx_http_v2_state_complete(h2c, pos + h2c->state.length, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2603 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2605 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2606 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2607 ngx_http_v2_state_save(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2608 ngx_http_v2_handler_pt handler) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2609 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2610 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2611 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2612 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2613 "http2 frame state save pos:%p end:%p handler:%p", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2614 pos, end, handler); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2615 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2616 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2617 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2618 if (size > NGX_HTTP_V2_STATE_BUFFER_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2619 ngx_log_error(NGX_LOG_ALERT, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2620 "state buffer overflow: %uz bytes required", size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2621 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2622 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2623 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2624 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2625 ngx_memcpy(h2c->state.buffer, pos, NGX_HTTP_V2_STATE_BUFFER_SIZE); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2626 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2627 h2c->state.buffer_used = size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2628 h2c->state.handler = handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2629 h2c->state.incomplete = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2630 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2631 return end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2632 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2633 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2634 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2635 static u_char * |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2636 ngx_http_v2_state_headers_save(ngx_http_v2_connection_t *h2c, u_char *pos, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2637 u_char *end, ngx_http_v2_handler_pt handler) |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2638 { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2639 ngx_event_t *rev; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2640 ngx_http_request_t *r; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2641 ngx_http_core_srv_conf_t *cscf; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2642 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2643 if (h2c->state.stream) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2644 r = h2c->state.stream->request; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2645 rev = r->connection->read; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2646 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2647 if (!rev->timer_set) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2648 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2649 ngx_add_timer(rev, cscf->client_header_timeout); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2650 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2651 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2652 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2653 return ngx_http_v2_state_save(h2c, pos, end, handler); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2654 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2655 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2656 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2657 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2658 ngx_http_v2_connection_error(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2659 ngx_uint_t err) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2660 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2661 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2662 "http2 state connection error"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2663 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2664 ngx_http_v2_finalize_connection(h2c, err); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2665 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2666 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2667 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2668 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2669 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2670 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2671 ngx_http_v2_parse_int(ngx_http_v2_connection_t *h2c, u_char **pos, u_char *end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2672 ngx_uint_t prefix) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2673 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2674 u_char *start, *p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2675 ngx_uint_t value, octet, shift; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2676 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2677 start = *pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2678 p = start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2679 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2680 value = *p++ & prefix; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2681 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2682 if (value != prefix) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2683 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2684 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2685 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2686 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2687 h2c->state.length--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2688 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2689 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2690 return value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2691 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2692 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2693 if (end - start > NGX_HTTP_V2_INT_OCTETS) { |
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2694 end = start + NGX_HTTP_V2_INT_OCTETS; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2695 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2696 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2697 for (shift = 0; p != end; shift += 7) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2698 octet = *p++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2699 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2700 value += (octet & 0x7f) << shift; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2701 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2702 if (octet < 128) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2703 if ((size_t) (p - start) > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2704 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2705 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2706 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2707 h2c->state.length -= p - start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2708 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2709 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2710 return value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2711 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2712 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2713 |
6268
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2714 if ((size_t) (end - start) >= h2c->state.length) { |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2715 return NGX_ERROR; |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2716 } |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2717 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2718 if (end == start + NGX_HTTP_V2_INT_OCTETS) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2719 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2720 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2721 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2722 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2723 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2724 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2725 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2726 ngx_http_v2_stream_t * |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2727 ngx_http_v2_push_stream(ngx_http_v2_stream_t *parent, ngx_str_t *path) |
7201 | 2728 { |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2729 ngx_int_t rc; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2730 ngx_str_t value; |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2731 ngx_pool_t *pool; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2732 ngx_uint_t index; |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2733 ngx_table_elt_t **h; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2734 ngx_connection_t *fc; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2735 ngx_http_request_t *r; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2736 ngx_http_v2_node_t *node; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2737 ngx_http_v2_stream_t *stream; |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2738 ngx_http_v2_srv_conf_t *h2scf; |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2739 ngx_http_v2_connection_t *h2c; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2740 ngx_http_v2_parse_header_t *header; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2741 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2742 h2c = parent->connection; |
7201 | 2743 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2744 pool = ngx_create_pool(1024, h2c->connection->log); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2745 if (pool == NULL) { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2746 goto rst_stream; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2747 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2748 |
7201 | 2749 node = ngx_http_v2_get_node_by_id(h2c, h2c->last_push, 1); |
2750 | |
2751 if (node == NULL) { | |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2752 ngx_destroy_pool(pool); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2753 goto rst_stream; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2754 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2755 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2756 stream = ngx_http_v2_create_stream(h2c, 1); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2757 if (stream == NULL) { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2758 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2759 if (node->parent == NULL) { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2760 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2761 ngx_http_v2_module); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2762 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2763 index = ngx_http_v2_index(h2scf, h2c->last_push); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2764 h2c->streams_index[index] = node->index; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2765 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2766 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2767 h2c->closed_nodes++; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2768 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2769 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2770 ngx_destroy_pool(pool); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2771 goto rst_stream; |
7201 | 2772 } |
2773 | |
2774 if (node->parent) { | |
2775 ngx_queue_remove(&node->reuse); | |
2776 h2c->closed_nodes--; | |
2777 } | |
2778 | |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2779 stream->pool = pool; |
7201 | 2780 |
2781 r = stream->request; | |
2782 fc = r->connection; | |
2783 | |
2784 stream->in_closed = 1; | |
2785 stream->node = node; | |
2786 | |
2787 node->stream = stream; | |
2788 | |
2789 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | |
2790 "http2 push stream sid:%ui " | |
2791 "depends on %ui excl:0 weight:16", | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2792 h2c->last_push, parent->node->id); |
7201 | 2793 |
2794 node->weight = NGX_HTTP_V2_DEFAULT_WEIGHT; | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2795 ngx_http_v2_set_dependency(h2c, node, parent->node->id, 0); |
7201 | 2796 |
2797 r->method_name = ngx_http_core_get_method; | |
2798 r->method = NGX_HTTP_GET; | |
2799 | |
7296
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2800 r->schema.data = ngx_pstrdup(pool, &parent->request->schema); |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2801 if (r->schema.data == NULL) { |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2802 goto close; |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2803 } |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2804 |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2805 r->schema.len = parent->request->schema.len; |
7201 | 2806 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2807 value.data = ngx_pstrdup(pool, path); |
7201 | 2808 if (value.data == NULL) { |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2809 goto close; |
7201 | 2810 } |
2811 | |
2812 value.len = path->len; | |
2813 | |
2814 rc = ngx_http_v2_parse_path(r, &value); | |
2815 | |
2816 if (rc != NGX_OK) { | |
2817 goto error; | |
2818 } | |
2819 | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2820 for (header = ngx_http_v2_parse_headers; header->name.len; header++) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2821 h = (ngx_table_elt_t **) |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2822 ((char *) &parent->request->headers_in + header->offset); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2823 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2824 if (*h == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2825 continue; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2826 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2827 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2828 value.len = (*h)->value.len; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2829 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2830 value.data = ngx_pnalloc(pool, value.len + 1); |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2831 if (value.data == NULL) { |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2832 goto close; |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2833 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2834 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2835 ngx_memcpy(value.data, (*h)->value.data, value.len); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2836 value.data[value.len] = '\0'; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2837 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2838 rc = ngx_http_v2_parse_header(r, header, &value); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2839 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2840 if (rc != NGX_OK) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2841 goto error; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2842 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2843 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2844 |
7201 | 2845 fc->write->handler = ngx_http_v2_run_request_handler; |
2846 ngx_post_event(fc->write, &ngx_posted_events); | |
2847 | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2848 return stream; |
7201 | 2849 |
2850 error: | |
2851 | |
2852 if (rc == NGX_ABORT) { | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2853 /* header handler has already finalized request */ |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
2854 ngx_http_run_posted_requests(fc); |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2855 return NULL; |
7201 | 2856 } |
2857 | |
2858 if (rc == NGX_DECLINED) { | |
2859 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
2860 ngx_http_run_posted_requests(fc); |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2861 return NULL; |
7201 | 2862 } |
2863 | |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2864 close: |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2865 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2866 ngx_http_v2_close_stream(stream, NGX_HTTP_INTERNAL_SERVER_ERROR); |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2867 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2868 return NULL; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2869 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2870 rst_stream: |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2871 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2872 if (ngx_http_v2_send_rst_stream(h2c, h2c->last_push, |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2873 NGX_HTTP_INTERNAL_SERVER_ERROR) |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2874 != NGX_OK) |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2875 { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2876 h2c->connection->error = 1; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2877 } |
7201 | 2878 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2879 return NULL; |
7201 | 2880 } |
2881 | |
2882 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2883 static ngx_int_t |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2884 ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2885 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2886 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2887 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2888 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2889 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2890 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2891 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2892 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2893 "http2 send SETTINGS frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2894 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2895 frame = ngx_palloc(h2c->pool, sizeof(ngx_http_v2_out_frame_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2896 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2897 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2898 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2899 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2900 cl = ngx_alloc_chain_link(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2901 if (cl == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2902 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2903 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2904 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2905 len = NGX_HTTP_V2_SETTINGS_PARAM_SIZE * 3; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2906 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2907 buf = ngx_create_temp_buf(h2c->pool, NGX_HTTP_V2_FRAME_HEADER_SIZE + len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2908 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2909 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2910 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2911 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2912 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2913 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2914 cl->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2915 cl->next = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2916 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2917 frame->first = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2918 frame->last = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2919 frame->handler = ngx_http_v2_settings_frame_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2920 frame->stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2921 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2922 frame->length = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2923 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2924 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2925 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2926 buf->last = ngx_http_v2_write_len_and_type(buf->last, len, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2927 NGX_HTTP_V2_SETTINGS_FRAME); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2928 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2929 *buf->last++ = NGX_HTTP_V2_NO_FLAG; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2930 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2931 buf->last = ngx_http_v2_write_sid(buf->last, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2932 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2933 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2934 ngx_http_v2_module); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2935 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2936 buf->last = ngx_http_v2_write_uint16(buf->last, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2937 NGX_HTTP_V2_MAX_STREAMS_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2938 buf->last = ngx_http_v2_write_uint32(buf->last, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2939 h2scf->concurrent_streams); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2940 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2941 buf->last = ngx_http_v2_write_uint16(buf->last, |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2942 NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING); |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2943 buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2944 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2945 buf->last = ngx_http_v2_write_uint16(buf->last, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2946 NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2947 buf->last = ngx_http_v2_write_uint32(buf->last, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2948 NGX_HTTP_V2_MAX_FRAME_SIZE); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2949 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2950 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2951 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2952 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2953 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2954 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2955 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2956 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2957 ngx_http_v2_settings_frame_handler(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2958 ngx_http_v2_out_frame_t *frame) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2959 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2960 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2961 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2962 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2963 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2964 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2965 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2966 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2967 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2968 ngx_free_chain(h2c->pool, frame->first); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2969 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2970 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2971 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2972 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2973 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2974 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2975 ngx_http_v2_send_window_update(ngx_http_v2_connection_t *h2c, ngx_uint_t sid, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2976 size_t window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2977 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2978 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2979 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2980 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2981 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2982 "http2 send WINDOW_UPDATE frame sid:%ui, window:%uz", |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2983 sid, window); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2984 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2985 frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_WINDOW_UPDATE_SIZE, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2986 NGX_HTTP_V2_WINDOW_UPDATE_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2987 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2988 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2989 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2990 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2991 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2992 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2993 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2994 buf->last = ngx_http_v2_write_uint32(buf->last, window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2995 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2996 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2997 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2998 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2999 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3000 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3001 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3002 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3003 ngx_http_v2_send_rst_stream(ngx_http_v2_connection_t *h2c, ngx_uint_t sid, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3004 ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3005 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3006 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3007 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3008 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3009 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
6790
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3010 "http2 send RST_STREAM frame sid:%ui, status:%ui", |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3011 sid, status); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3012 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3013 frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_RST_STREAM_SIZE, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3014 NGX_HTTP_V2_RST_STREAM_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3015 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3016 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3017 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3018 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3019 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3020 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3021 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3022 buf->last = ngx_http_v2_write_uint32(buf->last, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3023 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3024 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3025 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3026 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3027 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3028 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3029 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3030 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3031 ngx_http_v2_send_goaway(ngx_http_v2_connection_t *h2c, ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3032 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3033 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3034 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3035 |
6790
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3036 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3037 "http2 send GOAWAY frame: last sid %ui, error %ui", |
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3038 h2c->last_sid, status); |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3039 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3040 frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_GOAWAY_SIZE, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3041 NGX_HTTP_V2_GOAWAY_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3042 NGX_HTTP_V2_NO_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3043 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3044 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3045 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3046 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3047 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3048 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3049 buf->last = ngx_http_v2_write_sid(buf->last, h2c->last_sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3050 buf->last = ngx_http_v2_write_uint32(buf->last, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3051 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3052 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3053 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3054 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3055 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3056 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3057 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3058 static ngx_http_v2_out_frame_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3059 ngx_http_v2_get_frame(ngx_http_v2_connection_t *h2c, size_t length, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3060 ngx_uint_t type, u_char flags, ngx_uint_t sid) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3061 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3062 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3063 ngx_pool_t *pool; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3064 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3065 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3066 frame = h2c->free_frames; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3067 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3068 if (frame) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3069 h2c->free_frames = frame->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3070 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3071 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3072 buf->pos = buf->start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3073 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3074 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3075 |
7377 | 3076 } else if (h2c->frames < 10000) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3077 pool = h2c->pool ? h2c->pool : h2c->connection->pool; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3078 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3079 frame = ngx_pcalloc(pool, sizeof(ngx_http_v2_out_frame_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3080 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3081 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3082 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3083 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3084 frame->first = ngx_alloc_chain_link(pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3085 if (frame->first == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3086 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3087 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3088 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3089 buf = ngx_create_temp_buf(pool, NGX_HTTP_V2_FRAME_BUFFER_SIZE); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3090 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3091 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3092 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3093 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3094 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3095 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3096 frame->first->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3097 frame->last = frame->first; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3098 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3099 frame->handler = ngx_http_v2_frame_handler; |
7377 | 3100 |
3101 h2c->frames++; | |
3102 | |
3103 } else { | |
3104 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
3105 "http2 flood detected"); | |
3106 | |
3107 h2c->connection->error = 1; | |
3108 return NULL; | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3109 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3110 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3111 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3112 if (length > NGX_HTTP_V2_FRAME_BUFFER_SIZE - NGX_HTTP_V2_FRAME_HEADER_SIZE) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3113 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3114 ngx_log_error(NGX_LOG_ALERT, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3115 "requested control frame is too large: %uz", length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3116 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3117 } |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3118 #endif |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3119 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3120 frame->length = length; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3121 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3122 buf->last = ngx_http_v2_write_len_and_type(buf->pos, length, type); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3123 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3124 *buf->last++ = flags; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3125 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3126 buf->last = ngx_http_v2_write_sid(buf->last, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3127 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3128 return frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3129 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3130 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3131 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3132 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3133 ngx_http_v2_frame_handler(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3134 ngx_http_v2_out_frame_t *frame) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3135 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3136 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3137 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3138 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3139 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3140 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3141 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3142 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3143 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3144 frame->next = h2c->free_frames; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3145 h2c->free_frames = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3146 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3147 h2c->total_bytes += NGX_HTTP_V2_FRAME_HEADER_SIZE + frame->length; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3148 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3149 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3150 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3151 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3152 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3153 static ngx_http_v2_stream_t * |
7201 | 3154 ngx_http_v2_create_stream(ngx_http_v2_connection_t *h2c, ngx_uint_t push) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3155 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3156 ngx_log_t *log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3157 ngx_event_t *rev, *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3158 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3159 ngx_http_log_ctx_t *ctx; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3160 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3161 ngx_http_v2_stream_t *stream; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3162 ngx_http_v2_srv_conf_t *h2scf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3163 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3164 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3165 fc = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3167 if (fc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3168 h2c->free_fake_connections = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3169 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3170 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3171 wev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3172 log = fc->log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3173 ctx = log->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3174 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3175 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3176 fc = ngx_palloc(h2c->pool, sizeof(ngx_connection_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3177 if (fc == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3178 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3179 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3180 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3181 rev = ngx_palloc(h2c->pool, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3182 if (rev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3183 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3184 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3185 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3186 wev = ngx_palloc(h2c->pool, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3187 if (wev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3188 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3189 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3190 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3191 log = ngx_palloc(h2c->pool, sizeof(ngx_log_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3192 if (log == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3193 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3194 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3195 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3196 ctx = ngx_palloc(h2c->pool, sizeof(ngx_http_log_ctx_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3197 if (ctx == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3198 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3199 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3200 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3201 ctx->connection = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3202 ctx->request = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3203 ctx->current_request = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3204 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3205 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3206 ngx_memcpy(log, h2c->connection->log, sizeof(ngx_log_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3207 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3208 log->data = ctx; |
7201 | 3209 |
3210 if (push) { | |
3211 log->action = "processing pushed request headers"; | |
3212 | |
3213 } else { | |
3214 log->action = "reading client request headers"; | |
3215 } | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3216 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3217 ngx_memzero(rev, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3218 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3219 rev->data = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3220 rev->ready = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3221 rev->handler = ngx_http_v2_close_stream_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3222 rev->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3223 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3224 ngx_memcpy(wev, rev, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3225 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3226 wev->write = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3227 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3228 ngx_memcpy(fc, h2c->connection, sizeof(ngx_connection_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3229 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3230 fc->data = h2c->http_connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3231 fc->read = rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3232 fc->write = wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3233 fc->sent = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3234 fc->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3235 fc->buffered = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3236 fc->sndlowat = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3237 fc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3238 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3239 r = ngx_http_create_request(fc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3240 if (r == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3241 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3242 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3243 |
6256
9dfc4ba140f9
HTTP/2: fixed $server_protocol value (ticket #800).
Valentin Bartenev <vbart@nginx.com>
parents:
6249
diff
changeset
|
3244 ngx_str_set(&r->http_protocol, "HTTP/2.0"); |
9dfc4ba140f9
HTTP/2: fixed $server_protocol value (ticket #800).
Valentin Bartenev <vbart@nginx.com>
parents:
6249
diff
changeset
|
3245 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3246 r->http_version = NGX_HTTP_VERSION_20; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3247 r->valid_location = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3248 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3249 fc->data = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3250 h2c->connection->requests++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3251 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3252 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3253 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3254 r->header_in = ngx_create_temp_buf(r->pool, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3255 cscf->client_header_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3256 if (r->header_in == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3257 ngx_http_free_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3258 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3259 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3260 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3261 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3262 sizeof(ngx_table_elt_t)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3263 != NGX_OK) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3264 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3265 ngx_http_free_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3266 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3267 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3268 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3269 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3270 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3271 stream = ngx_pcalloc(r->pool, sizeof(ngx_http_v2_stream_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3272 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3273 ngx_http_free_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3274 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3275 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3276 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3277 r->stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3278 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3279 stream->request = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3280 stream->connection = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3281 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3282 h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3283 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3284 stream->send_window = h2c->init_window; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3285 stream->recv_window = h2scf->preread_size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3286 |
7201 | 3287 if (push) { |
3288 h2c->pushing++; | |
3289 | |
3290 } else { | |
3291 h2c->processing++; | |
3292 } | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3293 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3294 h2c->priority_limit += h2scf->concurrent_streams; |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3295 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3296 if (h2c->connection->read->timer_set) { |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3297 ngx_del_timer(h2c->connection->read); |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3298 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3299 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3300 return stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3301 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3302 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3303 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3304 static ngx_http_v2_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3305 ngx_http_v2_get_node_by_id(ngx_http_v2_connection_t *h2c, ngx_uint_t sid, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3306 ngx_uint_t alloc) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3307 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3308 ngx_uint_t index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3309 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3310 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3311 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3312 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3313 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3314 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3315 index = ngx_http_v2_index(h2scf, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3316 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3317 for (node = h2c->streams_index[index]; node; node = node->index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3318 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3319 if (node->id == sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3320 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3321 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3322 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3323 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3324 if (!alloc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3325 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3326 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3327 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3328 if (h2c->closed_nodes < 32) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3329 node = ngx_pcalloc(h2c->connection->pool, sizeof(ngx_http_v2_node_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3330 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3331 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3332 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3333 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3334 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3335 node = ngx_http_v2_get_closed_node(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3336 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3337 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3338 node->id = sid; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3339 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3340 ngx_queue_init(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3341 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3342 node->index = h2c->streams_index[index]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3343 h2c->streams_index[index] = node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3344 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3345 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3346 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3347 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3348 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3349 static ngx_http_v2_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3350 ngx_http_v2_get_closed_node(ngx_http_v2_connection_t *h2c) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3351 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3352 ngx_uint_t weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3353 ngx_queue_t *q, *children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3354 ngx_http_v2_node_t *node, **next, *n, *parent, *child; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3355 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3356 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3357 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3358 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3359 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3360 h2c->closed_nodes--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3361 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3362 q = ngx_queue_head(&h2c->closed); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3363 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3364 ngx_queue_remove(q); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3365 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3366 node = ngx_queue_data(q, ngx_http_v2_node_t, reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3367 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3368 next = &h2c->streams_index[ngx_http_v2_index(h2scf, node->id)]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3369 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3370 for ( ;; ) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3371 n = *next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3372 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3373 if (n == node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3374 *next = n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3375 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3376 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3377 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3378 next = &n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3379 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3380 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3381 ngx_queue_remove(&node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3382 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3383 weight = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3384 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3385 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3386 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3387 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3388 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3389 child = ngx_queue_data(q, ngx_http_v2_node_t, queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3390 weight += child->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3391 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3392 |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3393 parent = node->parent; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3394 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3395 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3396 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3397 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3398 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3399 child = ngx_queue_data(q, ngx_http_v2_node_t, queue); |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3400 child->parent = parent; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3401 child->weight = node->weight * child->weight / weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3402 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3403 if (child->weight == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3404 child->weight = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3405 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3406 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3407 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3408 if (parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3409 node->rank = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3410 node->rel_weight = 1.0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3411 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3412 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3413 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3414 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3415 node->rank = parent->rank; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3416 node->rel_weight = parent->rel_weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3417 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3418 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3419 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3420 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3421 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3422 ngx_queue_add(children, &node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3423 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3424 ngx_memzero(node, sizeof(ngx_http_v2_node_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3425 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3426 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3427 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3428 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3429 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3430 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3431 ngx_http_v2_validate_header(ngx_http_request_t *r, ngx_http_v2_header_t *header) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3432 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3433 u_char ch; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3434 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3435 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3436 |
6291
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3437 r->invalid_header = 0; |
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3438 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3439 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3440 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3441 for (i = (header->name.data[0] == ':'); i != header->name.len; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3442 ch = header->name.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3443 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3444 if ((ch >= 'a' && ch <= 'z') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3445 || (ch == '-') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3446 || (ch >= '0' && ch <= '9') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3447 || (ch == '_' && cscf->underscores_in_headers)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3448 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3449 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3450 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3451 |
7883
41f4bd4c51f1
Disabled control characters and space in header names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7877
diff
changeset
|
3452 if (ch <= 0x20 || ch == 0x7f || ch == ':' |
7216 | 3453 || (ch >= 'A' && ch <= 'Z')) |
3454 { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3455 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3456 "client sent invalid header name: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3457 &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3458 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3459 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3460 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3461 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3462 r->invalid_header = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3463 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3464 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3465 for (i = 0; i != header->value.len; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3466 ch = header->value.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3467 |
7216 | 3468 if (ch == '\0' || ch == LF || ch == CR) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3469 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3470 "client sent header \"%V\" with " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3471 "invalid value: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3472 &header->name, &header->value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3473 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3474 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3475 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3476 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3477 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3478 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3479 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3480 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3481 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3482 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3483 ngx_http_v2_pseudo_header(ngx_http_request_t *r, ngx_http_v2_header_t *header) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3484 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3485 header->name.len--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3486 header->name.data++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3487 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3488 switch (header->name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3489 case 4: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3490 if (ngx_memcmp(header->name.data, "path", sizeof("path") - 1) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3491 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3492 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3493 return ngx_http_v2_parse_path(r, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3494 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3495 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3496 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3497 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3498 case 6: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3499 if (ngx_memcmp(header->name.data, "method", sizeof("method") - 1) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3500 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3501 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3502 return ngx_http_v2_parse_method(r, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3503 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3504 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3505 if (ngx_memcmp(header->name.data, "scheme", sizeof("scheme") - 1) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3506 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3507 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3508 return ngx_http_v2_parse_scheme(r, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3509 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3510 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3511 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3512 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3513 case 9: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3514 if (ngx_memcmp(header->name.data, "authority", sizeof("authority") - 1) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3515 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3516 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3517 return ngx_http_v2_parse_authority(r, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3518 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3519 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3520 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3521 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3522 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3523 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
3524 "client sent unknown pseudo-header \":%V\"", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3525 &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3526 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3527 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3528 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3529 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3530 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3531 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3532 ngx_http_v2_parse_path(ngx_http_request_t *r, ngx_str_t *value) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3533 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3534 if (r->unparsed_uri.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3535 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3536 "client sent duplicate :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3537 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3538 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3539 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3540 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3541 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3542 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3543 "client sent empty :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3544 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3545 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3546 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3547 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3548 r->uri_start = value->data; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3549 r->uri_end = value->data + value->len; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3550 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3551 if (ngx_http_parse_uri(r) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3552 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3553 "client sent invalid :path header: \"%V\"", value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3554 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3555 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3556 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3557 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3558 if (ngx_http_process_request_uri(r) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3559 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3560 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3561 * in ngx_http_process_request_uri() |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3562 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3563 return NGX_ABORT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3564 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3565 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3566 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3567 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3568 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3569 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3570 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3571 ngx_http_v2_parse_method(ngx_http_request_t *r, ngx_str_t *value) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3572 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3573 size_t k, len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3574 ngx_uint_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3575 const u_char *p, *m; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3576 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3577 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3578 * This array takes less than 256 sequential bytes, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3579 * and if typical CPU cache line size is 64 bytes, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3580 * it is prefetched for 4 load operations. |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3581 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3582 static const struct { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3583 u_char len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3584 const u_char method[11]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3585 uint32_t value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3586 } tests[] = { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3587 { 3, "GET", NGX_HTTP_GET }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3588 { 4, "POST", NGX_HTTP_POST }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3589 { 4, "HEAD", NGX_HTTP_HEAD }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3590 { 7, "OPTIONS", NGX_HTTP_OPTIONS }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3591 { 8, "PROPFIND", NGX_HTTP_PROPFIND }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3592 { 3, "PUT", NGX_HTTP_PUT }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3593 { 5, "MKCOL", NGX_HTTP_MKCOL }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3594 { 6, "DELETE", NGX_HTTP_DELETE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3595 { 4, "COPY", NGX_HTTP_COPY }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3596 { 4, "MOVE", NGX_HTTP_MOVE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3597 { 9, "PROPPATCH", NGX_HTTP_PROPPATCH }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3598 { 4, "LOCK", NGX_HTTP_LOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3599 { 6, "UNLOCK", NGX_HTTP_UNLOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3600 { 5, "PATCH", NGX_HTTP_PATCH }, |
7877
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3601 { 5, "TRACE", NGX_HTTP_TRACE }, |
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3602 { 7, "CONNECT", NGX_HTTP_CONNECT } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3603 }, *test; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3605 if (r->method_name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3606 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3607 "client sent duplicate :method header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3608 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3609 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3610 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3611 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3612 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3613 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3614 "client sent empty :method header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3615 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3616 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3617 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3618 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3619 r->method_name.len = value->len; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3620 r->method_name.data = value->data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3621 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3622 len = r->method_name.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3623 n = sizeof(tests) / sizeof(tests[0]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3624 test = tests; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3625 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3626 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3627 if (len == test->len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3628 p = r->method_name.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3629 m = test->method; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3630 k = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3631 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3632 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3633 if (*p++ != *m++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3634 goto next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3635 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3636 } while (--k); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3637 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3638 r->method = test->value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3639 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3640 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3641 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3642 next: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3643 test++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3644 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3645 } while (--n); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3646 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3647 p = r->method_name.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3648 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3649 do { |
6732
57148b755320
Allowed '-' in method names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6642
diff
changeset
|
3650 if ((*p < 'A' || *p > 'Z') && *p != '_' && *p != '-') { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3651 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3652 "client sent invalid method: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3653 &r->method_name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3654 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3655 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3656 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3657 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3658 p++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3659 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3660 } while (--len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3661 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3662 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3663 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3664 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3665 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3666 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3667 ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3668 { |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3669 u_char c, ch; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3670 ngx_uint_t i; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3671 |
7295 | 3672 if (r->schema.len) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3673 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
3674 "client sent duplicate :scheme header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3675 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3676 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3677 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3678 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3679 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3680 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
3681 "client sent empty :scheme header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3682 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3683 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3684 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3685 |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3686 for (i = 0; i < value->len; i++) { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3687 ch = value->data[i]; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3688 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3689 c = (u_char) (ch | 0x20); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3690 if (c >= 'a' && c <= 'z') { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3691 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3692 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3693 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3694 if (((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3695 && i > 0) |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3696 { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3697 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3698 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3699 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3700 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3701 "client sent invalid :scheme header: \"%V\"", value); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3702 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3703 return NGX_DECLINED; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3704 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3705 |
7295 | 3706 r->schema = *value; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3707 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3708 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3709 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3710 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3711 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3712 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3713 ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_str_t *value) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3714 { |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3715 return ngx_http_v2_parse_header(r, &ngx_http_v2_parse_headers[0], value); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3716 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3717 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3718 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3719 static ngx_int_t |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3720 ngx_http_v2_parse_header(ngx_http_request_t *r, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3721 ngx_http_v2_parse_header_t *header, ngx_str_t *value) |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3722 { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3723 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3724 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3725 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3726 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3727 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3728 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3729 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3730 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3731 h->key.len = header->name.len; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3732 h->key.data = header->name.data; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3733 h->lowcase_key = header->name.data; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3734 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3735 if (header->hh == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3736 header->hash = ngx_hash_key(header->name.data, header->name.len); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3737 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3738 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3739 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3740 header->hh = ngx_hash_find(&cmcf->headers_in_hash, header->hash, |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3741 h->lowcase_key, h->key.len); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3742 if (header->hh == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3743 return NGX_ERROR; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3744 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3745 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3746 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3747 h->hash = header->hash; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3748 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3749 h->value.len = value->len; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3750 h->value.data = value->data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3751 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3752 if (header->hh->handler(r, h, header->hh->offset) != NGX_OK) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3753 /* header handler has already finalized request */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3754 return NGX_ABORT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3755 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3756 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3757 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3758 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3759 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3760 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3761 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3762 ngx_http_v2_construct_request_line(ngx_http_request_t *r) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3763 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3764 u_char *p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3765 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3766 static const u_char ending[] = " HTTP/2.0"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3767 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3768 if (r->method_name.len == 0 |
7295 | 3769 || r->schema.len == 0 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3770 || r->unparsed_uri.len == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3771 { |
7106
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3772 if (r->method_name.len == 0) { |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3773 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3774 "client sent no :method header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3775 |
7295 | 3776 } else if (r->schema.len == 0) { |
7106
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3777 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
3778 "client sent no :scheme header"); |
7106
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3779 |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3780 } else { |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3781 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3782 "client sent no :path header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3783 } |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3784 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3785 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3786 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3787 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3788 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3789 r->request_line.len = r->method_name.len + 1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3790 + r->unparsed_uri.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3791 + sizeof(ending) - 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3792 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3793 p = ngx_pnalloc(r->pool, r->request_line.len + 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3794 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3795 ngx_http_v2_close_stream(r->stream, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3796 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3797 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3798 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3799 r->request_line.data = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3800 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3801 p = ngx_cpymem(p, r->method_name.data, r->method_name.len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3802 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3803 *p++ = ' '; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3804 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3805 p = ngx_cpymem(p, r->unparsed_uri.data, r->unparsed_uri.len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3806 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3807 ngx_memcpy(p, ending, sizeof(ending)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3808 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3809 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7108
2bf605c6edf7
HTTP/2: shortened some debug log messages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7106
diff
changeset
|
3810 "http2 request line: \"%V\"", &r->request_line); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3811 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3812 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3813 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3814 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3815 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3816 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3817 ngx_http_v2_cookie(ngx_http_request_t *r, ngx_http_v2_header_t *header) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3818 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3819 ngx_str_t *val; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3820 ngx_array_t *cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3821 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3822 cookies = r->stream->cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3823 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3824 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3825 cookies = ngx_array_create(r->pool, 2, sizeof(ngx_str_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3826 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3827 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3828 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3829 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3830 r->stream->cookies = cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3831 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3832 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3833 val = ngx_array_push(cookies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3834 if (val == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3835 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3836 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3837 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3838 val->len = header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3839 val->data = header->value.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3840 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3841 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3842 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3843 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3844 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3845 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3846 ngx_http_v2_construct_cookie_header(ngx_http_request_t *r) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3847 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3848 u_char *buf, *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3849 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3850 ngx_str_t *vals; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3851 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3852 ngx_array_t *cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3853 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3854 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3855 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3856 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3857 static ngx_str_t cookie = ngx_string("cookie"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3858 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3859 cookies = r->stream->cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3860 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3861 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3862 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3863 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3864 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3865 vals = cookies->elts; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3866 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3867 i = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3868 len = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3869 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3870 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3871 len += vals[i].len + 2; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3872 } while (++i != cookies->nelts); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3873 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3874 len -= 2; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3875 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3876 buf = ngx_pnalloc(r->pool, len + 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3877 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3878 ngx_http_v2_close_stream(r->stream, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3879 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3880 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3881 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3882 p = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3883 end = buf + len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3884 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3885 for (i = 0; /* void */ ; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3886 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3887 p = ngx_cpymem(p, vals[i].data, vals[i].len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3888 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3889 if (p == end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3890 *p = '\0'; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3891 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3892 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3893 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3894 *p++ = ';'; *p++ = ' '; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3895 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3896 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3897 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3898 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3899 ngx_http_v2_close_stream(r->stream, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3900 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3901 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3902 |
7209
3dfe9444324b
HTTP/2: precalculate hash for "Cookie".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7208
diff
changeset
|
3903 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( |
3dfe9444324b
HTTP/2: precalculate hash for "Cookie".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7208
diff
changeset
|
3904 ngx_hash('c', 'o'), 'o'), 'k'), 'i'), 'e'); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3905 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3906 h->key.len = cookie.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3907 h->key.data = cookie.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3908 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3909 h->value.len = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3910 h->value.data = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3911 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3912 h->lowcase_key = cookie.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3913 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3914 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3915 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3916 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3917 h->lowcase_key, h->key.len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3918 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3919 if (hh == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3920 ngx_http_v2_close_stream(r->stream, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3921 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3922 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3923 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3924 if (hh->handler(r, h, hh->offset) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3925 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3926 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3927 * in ngx_http_process_multi_header_lines() |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3928 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3929 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3930 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3931 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3932 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3933 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3934 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3935 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3936 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3937 ngx_http_v2_run_request(ngx_http_request_t *r) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3938 { |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3939 ngx_connection_t *fc; |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3940 ngx_http_v2_srv_conf_t *h2scf; |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3941 ngx_http_v2_connection_t *h2c; |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3942 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3943 fc = r->connection; |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3944 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3945 h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3946 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3947 if (!h2scf->enable && !r->http_connection->addr_conf->http2) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3948 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3949 "client attempted to request the server name " |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3950 "for which the negotiated protocol is disabled"); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3951 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3952 ngx_http_finalize_request(r, NGX_HTTP_MISDIRECTED_REQUEST); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3953 goto failed; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3954 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3955 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3956 if (ngx_http_v2_construct_request_line(r) != NGX_OK) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3957 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3958 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3959 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3960 if (ngx_http_v2_construct_cookie_header(r) != NGX_OK) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3961 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3962 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3963 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3964 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3965 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3966 if (ngx_http_process_request_header(r) != NGX_OK) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3967 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3968 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3969 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3970 if (r->headers_in.content_length_n > 0 && r->stream->in_closed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3971 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3972 "client prematurely closed stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3973 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3974 r->stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3975 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3976 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3977 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3978 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3979 |
6589
78533a74af11
HTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev <vbart@nginx.com>
parents:
6588
diff
changeset
|
3980 if (r->headers_in.content_length_n == -1 && !r->stream->in_closed) { |
78533a74af11
HTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev <vbart@nginx.com>
parents:
6588
diff
changeset
|
3981 r->headers_in.chunked = 1; |
78533a74af11
HTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev <vbart@nginx.com>
parents:
6588
diff
changeset
|
3982 } |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
3983 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3984 h2c = r->stream->connection; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3985 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3986 h2c->payload_bytes += r->request_length; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3987 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3988 ngx_http_process_request(r); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3989 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3990 failed: |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3991 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3992 ngx_http_run_posted_requests(fc); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3993 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3994 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3995 |
7201 | 3996 static void |
3997 ngx_http_v2_run_request_handler(ngx_event_t *ev) | |
3998 { | |
3999 ngx_connection_t *fc; | |
4000 ngx_http_request_t *r; | |
4001 | |
4002 fc = ev->data; | |
4003 r = fc->data; | |
4004 | |
4005 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, | |
4006 "http2 run request handler"); | |
4007 | |
4008 ngx_http_v2_run_request(r); | |
4009 } | |
4010 | |
4011 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4012 ngx_int_t |
6989
2c4dbcd6f2e4
HTTP/2: reduced difference to HTTP/1.x in reading request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6988
diff
changeset
|
4013 ngx_http_v2_read_request_body(ngx_http_request_t *r) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4014 { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4015 off_t len; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4016 size_t size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4017 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4018 ngx_int_t rc; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4019 ngx_http_v2_stream_t *stream; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4020 ngx_http_v2_srv_conf_t *h2scf; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4021 ngx_http_request_body_t *rb; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4022 ngx_http_core_loc_conf_t *clcf; |
6520
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4023 ngx_http_v2_connection_t *h2c; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4024 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4025 stream = r->stream; |
6989
2c4dbcd6f2e4
HTTP/2: reduced difference to HTTP/1.x in reading request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6988
diff
changeset
|
4026 rb = r->request_body; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4027 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4028 if (stream->skip_data) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4029 r->request_body_no_buffering = 0; |
6989
2c4dbcd6f2e4
HTTP/2: reduced difference to HTTP/1.x in reading request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6988
diff
changeset
|
4030 rb->post_handler(r); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4031 return NGX_OK; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4032 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4033 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4034 rb->rest = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4035 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4036 /* set rb->filter_need_buffering */ |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4037 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4038 rc = ngx_http_top_request_body_filter(r, NULL); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4039 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4040 if (rc != NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4041 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4042 return rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4043 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4044 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4045 h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4046 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4047 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4048 len = r->headers_in.content_length_n; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4049 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4050 if (len < 0 || len > (off_t) clcf->client_body_buffer_size) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4051 len = clcf->client_body_buffer_size; |
7909
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
4052 |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
4053 } else { |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
4054 len++; |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4055 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4056 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4057 if (r->request_body_no_buffering || rb->filter_need_buffering) { |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4058 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4059 /* |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4060 * We need a room to store data up to the stream's initial window size, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4061 * at least until this window will be exhausted. |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4062 */ |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4063 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4064 if (len < (off_t) h2scf->preread_size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4065 len = h2scf->preread_size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4066 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4067 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4068 if (len > NGX_HTTP_V2_MAX_WINDOW) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4069 len = NGX_HTTP_V2_MAX_WINDOW; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4070 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4071 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4072 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4073 rb->buf = ngx_create_temp_buf(r->pool, (size_t) len); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4074 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4075 if (rb->buf == NULL) { |
6519
9ac934dd5dd8
HTTP/2: skip data frames in case of internal errors.
Valentin Bartenev <vbart@nginx.com>
parents:
6518
diff
changeset
|
4076 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4077 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4078 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4079 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4080 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4081 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4082 if (stream->in_closed) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4083 if (!rb->filter_need_buffering) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4084 r->request_body_no_buffering = 0; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4085 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4086 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4087 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4088 rc = ngx_http_v2_process_request_body(r, buf->pos, |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4089 buf->last - buf->pos, 1, 0); |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4090 ngx_pfree(r->pool, buf->start); |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4091 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4092 } else { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4093 rc = ngx_http_v2_process_request_body(r, NULL, 0, 1, 0); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4094 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4095 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4096 if (rc != NGX_AGAIN) { |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4097 return rc; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4098 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4099 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4100 r->read_event_handler = ngx_http_v2_read_client_request_body_handler; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4101 r->write_event_handler = ngx_http_request_empty_handler; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4102 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4103 return NGX_AGAIN; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4104 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4105 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4106 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4107 rc = ngx_http_v2_process_request_body(r, buf->pos, |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4108 buf->last - buf->pos, 0, 0); |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4109 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4110 ngx_pfree(r->pool, buf->start); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4111 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4112 if (rc != NGX_OK && rc != NGX_AGAIN) { |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4113 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4114 return rc; |
6518
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4115 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4116 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4117 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4118 if (r->request_body_no_buffering || rb->filter_need_buffering) { |
6572
bc6fd7afeed6
HTTP/2: unbreak build on MSVC.
Valentin Bartenev <vbart@nginx.com>
parents:
6566
diff
changeset
|
4119 size = (size_t) len - h2scf->preread_size; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4120 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4121 } else { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4122 stream->no_flow_control = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4123 size = NGX_HTTP_V2_MAX_WINDOW - stream->recv_window; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4124 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4125 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4126 if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4127 if (ngx_http_v2_send_window_update(stream->connection, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4128 stream->node->id, size) |
6518
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4129 == NGX_ERROR) |
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4130 { |
6519
9ac934dd5dd8
HTTP/2: skip data frames in case of internal errors.
Valentin Bartenev <vbart@nginx.com>
parents:
6518
diff
changeset
|
4131 stream->skip_data = 1; |
6518
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4132 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4133 } |
6520
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4134 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4135 h2c = stream->connection; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4136 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4137 if (!h2c->blocked) { |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4138 if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4139 stream->skip_data = 1; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4140 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4141 } |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4142 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4143 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4144 stream->recv_window += size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4145 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4146 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4147 if (!buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4148 ngx_add_timer(r->connection->read, clcf->client_body_timeout); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4149 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4150 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4151 r->read_event_handler = ngx_http_v2_read_client_request_body_handler; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4152 r->write_event_handler = ngx_http_request_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4153 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4154 return NGX_AGAIN; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4155 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4156 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4157 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4158 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4159 ngx_http_v2_process_request_body(ngx_http_request_t *r, u_char *pos, |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4160 size_t size, ngx_uint_t last, ngx_uint_t flush) |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4161 { |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4162 size_t n; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4163 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4164 ngx_connection_t *fc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4165 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4166 ngx_http_core_loc_conf_t *clcf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4167 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4168 fc = r->connection; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4169 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4170 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4171 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4172 "http2 process request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4173 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4174 if (size == 0 && !last && !flush) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4175 return NGX_AGAIN; |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4176 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4177 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4178 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4179 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4180 if (rb->buf->last == rb->buf->end && size) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4181 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4182 if (r->request_body_no_buffering) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4183 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4184 /* should never happen due to flow control */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4185 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4186 ngx_log_error(NGX_LOG_ALERT, fc->log, 0, |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4187 "no space in http2 body buffer"); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4188 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4189 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4190 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4191 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4192 /* update chains */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4193 |
7921 | 4194 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
4195 "http2 body update chains"); | |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4196 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4197 rc = ngx_http_v2_filter_request_body(r); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4198 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4199 if (rc != NGX_OK) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4200 return rc; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4201 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4202 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4203 if (rb->busy != NULL) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4204 ngx_log_error(NGX_LOG_ALERT, fc->log, 0, |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4205 "busy buffers after request body flush"); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4206 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4207 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4208 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4209 rb->buf->pos = rb->buf->start; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4210 rb->buf->last = rb->buf->start; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4211 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4212 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4213 /* copy body data to the buffer */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4214 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4215 n = rb->buf->end - rb->buf->last; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4216 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4217 if (n > size) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4218 n = size; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4219 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4220 |
7916
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4221 if (n > 0) { |
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4222 rb->buf->last = ngx_cpymem(rb->buf->last, pos, n); |
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4223 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4224 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4225 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4226 "http2 request body recv %uz", n); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4227 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4228 pos += n; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4229 size -= n; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4230 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4231 if (size == 0 && last) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4232 rb->rest = 0; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4233 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4234 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4235 if (size == 0) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4236 break; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4237 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4238 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4239 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4240 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4241 "http2 request body rest %O", rb->rest); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4242 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4243 if (flush) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4244 rc = ngx_http_v2_filter_request_body(r); |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4245 |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4246 if (rc != NGX_OK) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4247 return rc; |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4248 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4249 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4250 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4251 if (rb->rest == 0 && rb->last_saved) { |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4252 break; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4253 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4254 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4255 if (size == 0) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4256 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4257 ngx_add_timer(fc->read, clcf->client_body_timeout); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4258 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4259 if (!flush) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4260 ngx_post_event(fc->read, &ngx_posted_events); |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4261 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4262 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4263 return NGX_AGAIN; |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4264 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4265 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4266 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4267 if (fc->read->timer_set) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4268 ngx_del_timer(fc->read); |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4269 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4270 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4271 if (r->request_body_no_buffering) { |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4272 if (!flush) { |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4273 ngx_post_event(fc->read, &ngx_posted_events); |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4274 } |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4275 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4276 return NGX_OK; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4277 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4278 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4279 if (r->headers_in.chunked) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4280 r->headers_in.content_length_n = rb->received; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4281 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4282 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4283 r->read_event_handler = ngx_http_block_reading; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4284 rb->post_handler(r); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4285 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4286 return NGX_OK; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4287 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4288 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4289 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4290 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4291 ngx_http_v2_filter_request_body(ngx_http_request_t *r) |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4292 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4293 ngx_buf_t *b, *buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4294 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4295 ngx_chain_t *cl; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4296 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4297 ngx_http_core_loc_conf_t *clcf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4298 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4299 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4300 buf = rb->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4301 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4302 if (buf->pos == buf->last && (rb->rest || rb->last_sent)) { |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4303 cl = NULL; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4304 goto update; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4305 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4306 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4307 cl = ngx_chain_get_free_buf(r->pool, &rb->free); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4308 if (cl == NULL) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4309 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4310 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4311 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4312 b = cl->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4313 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4314 ngx_memzero(b, sizeof(ngx_buf_t)); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4315 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4316 if (buf->pos != buf->last) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4317 r->request_length += buf->last - buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4318 rb->received += buf->last - buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4319 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4320 if (r->headers_in.content_length_n != -1) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4321 if (rb->received > r->headers_in.content_length_n) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4322 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4323 "client intended to send body data " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4324 "larger than declared"); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4325 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4326 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4327 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4328 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4329 } else { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4330 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4331 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4332 if (clcf->client_max_body_size |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4333 && rb->received > clcf->client_max_body_size) |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4334 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4335 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4336 "client intended to send too large chunked body: " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4337 "%O bytes", rb->received); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4338 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4339 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4340 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4341 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4342 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4343 b->temporary = 1; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4344 b->pos = buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4345 b->last = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4346 b->start = b->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4347 b->end = b->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4348 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4349 buf->pos = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4350 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4351 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4352 if (!rb->rest) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4353 if (r->headers_in.content_length_n != -1 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4354 && r->headers_in.content_length_n != rb->received) |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4355 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4356 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4357 "client prematurely closed stream: " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4358 "only %O out of %O bytes of request body received", |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4359 rb->received, r->headers_in.content_length_n); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4360 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4361 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4362 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4363 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4364 b->last_buf = 1; |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4365 rb->last_sent = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4366 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4367 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4368 b->tag = (ngx_buf_tag_t) &ngx_http_v2_filter_request_body; |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4369 b->flush = r->request_body_no_buffering; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4370 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4371 update: |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4372 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4373 rc = ngx_http_top_request_body_filter(r, cl); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4374 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4375 ngx_chain_update_chains(r->pool, &rb->free, &rb->busy, &cl, |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4376 (ngx_buf_tag_t) &ngx_http_v2_filter_request_body); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4377 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4378 return rc; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4379 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4380 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4381 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4382 static void |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4383 ngx_http_v2_read_client_request_body_handler(ngx_http_request_t *r) |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4384 { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4385 size_t window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4386 ngx_buf_t *buf; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4387 ngx_int_t rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4388 ngx_connection_t *fc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4389 ngx_http_v2_stream_t *stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4390 ngx_http_v2_connection_t *h2c; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4391 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4392 fc = r->connection; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4393 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4394 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4395 "http2 read client request body handler"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4396 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4397 if (fc->read->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4398 ngx_log_error(NGX_LOG_INFO, fc->log, NGX_ETIMEDOUT, "client timed out"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4399 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4400 fc->timedout = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4401 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4402 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4403 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4404 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4405 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4406 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4407 if (fc->error) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4408 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4409 "client prematurely closed stream"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4410 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4411 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4412 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4413 ngx_http_finalize_request(r, NGX_HTTP_CLIENT_CLOSED_REQUEST); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4414 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4415 } |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4416 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4417 rc = ngx_http_v2_process_request_body(r, NULL, 0, r->stream->in_closed, 1); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4418 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4419 if (rc != NGX_OK && rc != NGX_AGAIN) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4420 r->stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4421 ngx_http_finalize_request(r, rc); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4422 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4423 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4424 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4425 if (rc == NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4426 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4427 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4428 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4429 if (r->stream->no_flow_control) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4430 return; |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4431 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4432 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4433 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4434 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4435 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4436 |
7922
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4437 if (r->request_body->busy != NULL) { |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4438 return; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4439 } |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4440 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4441 stream = r->stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4442 h2c = stream->connection; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4443 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4444 buf = r->request_body->buf; |
7922
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4445 |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4446 buf->pos = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4447 buf->last = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4448 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4449 window = buf->end - buf->start; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4450 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4451 if (h2c->state.stream == stream) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4452 window -= h2c->state.length; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4453 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4454 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4455 if (window <= stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4456 if (window < stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4457 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4458 "http2 negative window update"); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4459 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4460 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4461 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4462 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4463 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4464 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4465 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4466 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4467 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4468 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4469 if (ngx_http_v2_send_window_update(h2c, stream->node->id, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4470 window - stream->recv_window) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4471 == NGX_ERROR) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4472 { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4473 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4474 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4475 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4476 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4477 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4478 stream->recv_window = window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4479 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4480 if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4481 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4482 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4483 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4484 } |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4485 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4486 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4487 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4488 ngx_int_t |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4489 ngx_http_v2_read_unbuffered_request_body(ngx_http_request_t *r) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4490 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4491 size_t window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4492 ngx_buf_t *buf; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4493 ngx_int_t rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4494 ngx_connection_t *fc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4495 ngx_http_v2_stream_t *stream; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4496 ngx_http_v2_connection_t *h2c; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4497 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4498 stream = r->stream; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4499 fc = r->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4500 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4501 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4502 "http2 read unbuffered request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4503 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4504 if (fc->read->timedout) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4505 if (stream->recv_window) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4506 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4507 fc->timedout = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4508 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4509 return NGX_HTTP_REQUEST_TIME_OUT; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4510 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4511 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4512 fc->read->timedout = 0; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4513 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4514 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4515 if (fc->error) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4516 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4517 return NGX_HTTP_BAD_REQUEST; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4518 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4519 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4520 rc = ngx_http_v2_process_request_body(r, NULL, 0, r->stream->in_closed, 1); |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4521 |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4522 if (rc != NGX_OK && rc != NGX_AGAIN) { |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4523 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4524 return rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4525 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4526 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4527 if (rc == NGX_OK) { |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4528 return NGX_OK; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4529 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4530 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4531 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4532 return NGX_AGAIN; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4533 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4534 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4535 if (r->request_body->busy != NULL) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4536 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4537 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4538 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4539 buf = r->request_body->buf; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4540 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4541 buf->pos = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4542 buf->last = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4543 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4544 window = buf->end - buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4545 h2c = stream->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4546 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4547 if (h2c->state.stream == stream) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4548 window -= h2c->state.length; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4549 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4550 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4551 if (window <= stream->recv_window) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4552 if (window < stream->recv_window) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4553 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4554 "http2 negative window update"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4555 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4556 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4557 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4558 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4559 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4560 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4561 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4562 if (ngx_http_v2_send_window_update(h2c, stream->node->id, |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4563 window - stream->recv_window) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4564 == NGX_ERROR) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4565 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4566 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4567 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4568 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4569 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4570 if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4571 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4572 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4573 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4574 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4575 stream->recv_window = window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4576 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4577 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4578 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4579 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4580 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4581 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4582 ngx_http_v2_terminate_stream(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4583 ngx_http_v2_stream_t *stream, ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4584 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4585 ngx_event_t *rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4586 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4587 |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4588 if (stream->rst_sent) { |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4589 return NGX_OK; |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4590 } |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4591 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4592 if (ngx_http_v2_send_rst_stream(h2c, stream->node->id, status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4593 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4594 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4595 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4596 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4597 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4598 stream->rst_sent = 1; |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4599 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4600 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4601 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4602 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4603 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4604 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4605 rev->handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4606 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4607 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4608 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4609 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4610 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4611 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4612 ngx_http_v2_close_stream(ngx_http_v2_stream_t *stream, ngx_int_t rc) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4613 { |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4614 ngx_pool_t *pool; |
7201 | 4615 ngx_uint_t push; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4616 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4617 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4618 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4619 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4620 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4621 h2c = stream->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4622 node = stream->node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4623 |
7201 | 4624 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
4625 "http2 close stream %ui, queued %ui, " | |
4626 "processing %ui, pushing %ui", | |
4627 node->id, stream->queued, h2c->processing, h2c->pushing); | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4628 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4629 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4630 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4631 if (stream->queued) { |
7610
82c1339e2637
HTTP/2: fixed socket leak with queued frames (ticket #1689).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7571
diff
changeset
|
4632 fc->error = 1; |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4633 fc->write->handler = ngx_http_v2_retry_close_stream_handler; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4634 fc->read->handler = ngx_http_v2_retry_close_stream_handler; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4635 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4636 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4637 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4638 if (!stream->rst_sent && !h2c->connection->error) { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4639 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4640 if (!stream->out_closed) { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4641 if (ngx_http_v2_send_rst_stream(h2c, node->id, |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4642 fc->timedout ? NGX_HTTP_V2_PROTOCOL_ERROR |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4643 : NGX_HTTP_V2_INTERNAL_ERROR) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4644 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4645 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4646 h2c->connection->error = 1; |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4647 } |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4648 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4649 } else if (!stream->in_closed) { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4650 if (ngx_http_v2_send_rst_stream(h2c, node->id, NGX_HTTP_V2_NO_ERROR) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4651 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4652 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4653 h2c->connection->error = 1; |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4654 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4655 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4656 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4657 |
6410
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4658 if (h2c->state.stream == stream) { |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4659 h2c->state.stream = NULL; |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4660 } |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4661 |
7201 | 4662 push = stream->node->id % 2 == 0; |
4663 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4664 node->stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4665 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4666 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4667 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4668 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4669 /* |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4670 * This pool keeps decoded request headers which can be used by log phase |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4671 * handlers in ngx_http_free_request(). |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4672 * |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4673 * The pointer is stored into local variable because the stream object |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4674 * will be destroyed after a call to ngx_http_free_request(). |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4675 */ |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4676 pool = stream->pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4677 |
7548
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4678 h2c->frames -= stream->frames; |
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4679 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4680 ngx_http_free_request(stream->request, rc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4681 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4682 if (pool != h2c->state.pool) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4683 ngx_destroy_pool(pool); |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4684 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4685 } else { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4686 /* pool will be destroyed when the complete header is parsed */ |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4687 h2c->state.keep_pool = 0; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4688 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4689 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4690 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4691 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4692 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4693 ngx_del_timer(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4694 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4695 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4696 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4697 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4698 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4699 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4700 ev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4701 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4702 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4703 ngx_del_timer(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4704 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4705 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4706 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4707 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4708 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4709 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4710 fc->data = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4711 h2c->free_fake_connections = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4712 |
7201 | 4713 if (push) { |
4714 h2c->pushing--; | |
4715 | |
4716 } else { | |
4717 h2c->processing--; | |
4718 } | |
4719 | |
4720 if (h2c->processing || h2c->pushing || h2c->blocked) { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4721 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4722 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4723 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4724 ev = h2c->connection->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4725 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4726 ev->handler = ngx_http_v2_handle_connection_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4727 ngx_post_event(ev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4728 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4729 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4730 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4731 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4732 ngx_http_v2_close_stream_handler(ngx_event_t *ev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4733 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4734 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4735 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4736 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4737 fc = ev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4738 r = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4739 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4740 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4741 "http2 close stream handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4742 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4743 if (ev->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4744 ngx_log_error(NGX_LOG_INFO, fc->log, NGX_ETIMEDOUT, "client timed out"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4745 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4746 fc->timedout = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4747 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4748 ngx_http_v2_close_stream(r->stream, NGX_HTTP_REQUEST_TIME_OUT); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4749 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4750 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4751 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4752 ngx_http_v2_close_stream(r->stream, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4753 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4754 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4755 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4756 static void |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4757 ngx_http_v2_retry_close_stream_handler(ngx_event_t *ev) |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4758 { |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4759 ngx_connection_t *fc; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4760 ngx_http_request_t *r; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4761 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4762 fc = ev->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4763 r = fc->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4764 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4765 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4766 "http2 retry close stream handler"); |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4767 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4768 ngx_http_v2_close_stream(r->stream, 0); |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4769 } |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4770 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4771 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4772 static void |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4773 ngx_http_v2_handle_connection_handler(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4774 { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4775 ngx_connection_t *c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4776 ngx_http_v2_connection_t *h2c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4777 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4778 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4779 "http2 handle connection handler"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4780 |
6957
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4781 c = rev->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4782 h2c = c->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4783 |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4784 if (c->error) { |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4785 ngx_http_v2_finalize_connection(h2c, 0); |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4786 return; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4787 } |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4788 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4789 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4790 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4791 if (rev->ready) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4792 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4793 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4794 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4795 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4796 if (h2c->last_out && ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4797 ngx_http_v2_finalize_connection(h2c, 0); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4798 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4799 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4800 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4801 ngx_http_v2_handle_connection(c->data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4802 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4803 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4804 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4805 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4806 ngx_http_v2_idle_handler(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4807 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4808 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4809 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4810 ngx_http_v2_connection_t *h2c; |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4811 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4812 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4813 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4814 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4815 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4816 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http2 idle handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4817 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4818 if (rev->timedout || c->close) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4819 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4820 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4821 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4822 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4823 #if (NGX_HAVE_KQUEUE) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4824 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4825 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4826 if (rev->pending_eof) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4827 c->log->handler = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4828 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4829 "kevent() reported that client %V closed " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4830 "idle connection", &c->addr_text); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4831 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4832 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4833 c->ssl->no_send_shutdown = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4834 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4835 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4836 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4837 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4838 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4839 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4840 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4841 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4842 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4843 clcf = ngx_http_get_module_loc_conf(h2c->http_connection->conf_ctx, |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4844 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4845 |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4846 if (h2c->idle++ > 10 * clcf->keepalive_requests) { |
7378
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4847 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4848 "http2 flood detected"); |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4849 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR); |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4850 return; |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4851 } |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4852 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4853 c->destroyed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4854 ngx_reusable_connection(c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4855 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4856 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4857 ngx_http_v2_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4858 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4859 h2c->pool = ngx_create_pool(h2scf->pool_size, h2c->connection->log); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4860 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4861 ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4862 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4863 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4864 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4865 c->write->handler = ngx_http_v2_write_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4866 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4867 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4868 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4869 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4870 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4871 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4872 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4873 ngx_http_v2_finalize_connection(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4874 ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4875 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4876 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4877 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4878 ngx_connection_t *c, *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4879 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4880 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4881 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4882 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4883 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4884 c = h2c->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4885 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4886 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4887 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4888 if (!c->error && !h2c->goaway) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4889 h2c->goaway = 1; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4890 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4891 if (ngx_http_v2_send_goaway(h2c, status) != NGX_ERROR) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4892 (void) ngx_http_v2_send_output_queue(h2c); |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4893 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4894 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4895 |
7201 | 4896 if (!h2c->processing && !h2c->pushing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4897 goto done; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4898 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4899 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4900 c->read->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4901 c->write->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4902 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4903 h2c->last_out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4904 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4905 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4906 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4907 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4908 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4909 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4910 for (i = 0; i < size; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4911 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4912 for (node = h2c->streams_index[i]; node; node = node->index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4913 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4914 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4915 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4916 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4917 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4918 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
4919 stream->waiting = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4920 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4921 r = stream->request; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4922 fc = r->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4923 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4924 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4925 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4926 if (stream->queued) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4927 stream->queued = 0; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4928 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4929 ev = fc->write; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4930 ev->active = 0; |
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4931 ev->ready = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4932 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4933 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4934 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4935 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4936 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4937 ev->eof = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4938 ev->handler(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4939 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4940 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4941 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4942 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4943 |
7201 | 4944 if (h2c->processing || h2c->pushing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4945 c->error = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4946 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4947 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4948 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4949 done: |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4950 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4951 if (c->error) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4952 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4953 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4954 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4955 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
4956 ngx_http_v2_lingering_close(c); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4957 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4958 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4959 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4960 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4961 ngx_http_v2_adjust_windows(ngx_http_v2_connection_t *h2c, ssize_t delta) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4962 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4963 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4964 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4965 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4966 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4967 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4968 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4969 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4970 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4971 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4972 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4973 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4974 for (i = 0; i < size; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4975 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4976 for (node = h2c->streams_index[i]; node; node = node->index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4977 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4978 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4979 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4980 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4981 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4982 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4983 if (delta > 0 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4984 && stream->send_window |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4985 > (ssize_t) (NGX_HTTP_V2_MAX_WINDOW - delta)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4986 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4987 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4988 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4989 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4990 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4991 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4992 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4993 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4994 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4995 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4996 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4997 stream->send_window += delta; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4998 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4999 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5000 "http2:%ui adjusted window: %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5001 node->id, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5002 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5003 if (stream->send_window > 0 && stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5004 stream->exhausted = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5005 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5006 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5007 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5008 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5009 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5010 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5011 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5012 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5013 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5014 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5015 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5016 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5017 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5018 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5019 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5020 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5021 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5022 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5023 ngx_http_v2_set_dependency(ngx_http_v2_connection_t *h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5024 ngx_http_v2_node_t *node, ngx_uint_t depend, ngx_uint_t exclusive) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5025 { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5026 ngx_queue_t *children, *q; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5027 ngx_http_v2_node_t *parent, *child, *next; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5028 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5029 parent = depend ? ngx_http_v2_get_node_by_id(h2c, depend, 0) : NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5030 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5031 if (parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5032 parent = NGX_HTTP_V2_ROOT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5033 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5034 if (depend != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5035 exclusive = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5036 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5037 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5038 node->rank = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5039 node->rel_weight = (1.0 / 256) * node->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5040 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5041 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5042 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5043 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5044 if (node->parent != NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5045 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5046 for (next = parent->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5047 next != NGX_HTTP_V2_ROOT && next->rank >= node->rank; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5048 next = next->parent) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5049 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5050 if (next != node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5051 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5052 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5053 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5054 ngx_queue_remove(&parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5055 ngx_queue_insert_after(&node->queue, &parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5056 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5057 parent->parent = node->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5058 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5059 if (node->parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5060 parent->rank = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5061 parent->rel_weight = (1.0 / 256) * parent->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5062 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5063 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5064 parent->rank = node->parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5065 parent->rel_weight = (node->parent->rel_weight / 256) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5066 * parent->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5067 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5068 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5069 if (!exclusive) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5070 ngx_http_v2_node_children_update(parent); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5071 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5072 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5073 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5074 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5075 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5076 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5077 node->rank = parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5078 node->rel_weight = (parent->rel_weight / 256) * node->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5079 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5080 if (parent->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5081 ngx_queue_remove(&parent->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5082 ngx_queue_insert_tail(&h2c->closed, &parent->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5083 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5084 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5085 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5086 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5087 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5088 if (exclusive) { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5089 for (q = ngx_queue_head(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5090 q != ngx_queue_sentinel(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5091 q = ngx_queue_next(q)) |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5092 { |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5093 child = ngx_queue_data(q, ngx_http_v2_node_t, queue); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5094 child->parent = node; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5095 } |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5096 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5097 ngx_queue_add(&node->children, children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5098 ngx_queue_init(children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5099 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5100 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5101 if (node->parent != NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5102 ngx_queue_remove(&node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5103 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5104 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5105 ngx_queue_insert_tail(children, &node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5106 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5107 node->parent = parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5108 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5109 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5110 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5111 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5112 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5113 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5114 ngx_http_v2_node_children_update(ngx_http_v2_node_t *node) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5115 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5116 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5117 ngx_http_v2_node_t *child; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5118 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5119 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5120 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5121 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5122 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5123 child = ngx_queue_data(q, ngx_http_v2_node_t, queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5124 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5125 child->rank = node->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5126 child->rel_weight = (node->rel_weight / 256) * child->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5127 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5128 ngx_http_v2_node_children_update(child); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5129 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5130 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5131 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5132 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5133 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5134 ngx_http_v2_pool_cleanup(void *data) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5135 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5136 ngx_http_v2_connection_t *h2c = data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5137 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5138 if (h2c->state.pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5139 ngx_destroy_pool(h2c->state.pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5140 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5141 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5142 if (h2c->pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5143 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5144 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5145 } |