Mercurial > hg > nginx
annotate src/http/v2/ngx_http_v2.c @ 7923:4775c1d27378
HTTP/2: fixed timers left after request body reading.
Following rb->filter_need_buffering changes, request body reading is
only finished after the filter chain is called and rb->last_saved is set.
As such, with r->request_body_no_buffering, timer on fc->read is no
longer removed when the last part of the body is received, potentially
resulting in incorrect behaviour.
The fix is to call ngx_http_v2_process_request_body() from the
ngx_http_v2_read_unbuffered_request_body() function instead of
directly calling ngx_http_v2_filter_request_body(), so the timer
is properly removed.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 Sep 2021 14:54:48 +0300 |
parents | e9f402bfe37e |
children | d9e009b39596 |
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_proxy_protocol(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(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_preface_end(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_head(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_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_read_data(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_headers(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_header_block(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_len(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_huff(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_raw(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_field_skip(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_process_header(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); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
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_rst_stream(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(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_settings_params(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_push_promise(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_ping(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_goaway(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_window_update(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_continuation(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_complete(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_padded(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_skip(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); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 ngx_uint_t err); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
126 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
127 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
|
128 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
|
129 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
130 static ngx_http_v2_stream_t *ngx_http_v2_create_stream( |
7201 | 131 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
|
132 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
|
133 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
|
134 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
|
135 ngx_http_v2_connection_t *h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
136 #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
|
137 #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
|
138 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 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
|
143 ngx_uint_t sid, size_t window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
144 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
|
145 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
|
146 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
|
147 ngx_uint_t status); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
148 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
149 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
|
150 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
|
151 u_char flags, ngx_uint_t sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
152 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
|
153 ngx_http_v2_out_frame_t *frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
154 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
155 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
|
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_pseudo_header(ngx_http_request_t *r, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
158 ngx_http_v2_header_t *header); |
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_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
|
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_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
|
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_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
|
164 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
165 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
|
166 ngx_str_t *value); |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
172 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
|
173 static void ngx_http_v2_run_request(ngx_http_request_t *r); |
7201 | 174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 ngx_uint_t status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
188 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
189 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
|
190 ssize_t delta); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
195 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
|
196 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
197 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 }; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
210 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
211 #define NGX_HTTP_V2_FRAME_STATES \ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
212 (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
|
213 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
214 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
215 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
|
216 { ngx_string("host"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
217 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
|
218 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
219 { ngx_string("accept-encoding"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
220 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
|
221 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
222 { ngx_string("accept-language"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
223 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
|
224 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
225 { ngx_string("user-agent"), |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
226 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
|
227 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
228 { ngx_null_string, 0, 0, NULL } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
229 }; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
230 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
231 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
232 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
233 ngx_http_v2_init(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
234 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
235 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
236 ngx_pool_cleanup_t *cln; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
237 ngx_http_connection_t *hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
238 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
239 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
240 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
|
241 ngx_http_core_srv_conf_t *cscf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
242 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
243 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
244 hc = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
245 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
246 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
|
247 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
248 c->log->action = "processing HTTP/2 connection"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
249 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
250 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
|
251 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
252 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
253 h2mcf->recv_buffer = ngx_palloc(ngx_cycle->pool, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
254 h2mcf->recv_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
255 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
256 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
257 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
261 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
|
262 if (h2c == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
263 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
264 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
267 h2c->connection = c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
268 h2c->http_connection = hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
269 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
270 h2c->send_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
271 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
272 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
273 h2c->init_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
274 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
275 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
|
276 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
277 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
|
278 |
7201 | 279 h2c->concurrent_pushes = h2scf->concurrent_pushes; |
7819
3674d5b7174e
HTTP/2: relaxed PRIORITY frames limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7805
diff
changeset
|
280 h2c->priority_limit = ngx_max(h2scf->concurrent_streams, 100); |
7201 | 281 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
282 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
|
283 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
284 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
285 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
286 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
287 |
6374
f598de1bfcd4
HTTP/2: fixed excessive memory allocation for pool cleanup.
Valentin Bartenev <vbart@nginx.com>
parents:
6312
diff
changeset
|
288 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
|
289 if (cln == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
290 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
291 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
294 cln->handler = ngx_http_v2_pool_cleanup; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
295 cln->data = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
296 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
297 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
|
298 * sizeof(ngx_http_v2_node_t *)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
299 if (h2c->streams_index == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
300 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
301 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
302 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
303 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
304 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
|
305 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
306 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
309 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
|
310 - NGX_HTTP_V2_DEFAULT_WINDOW) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
311 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
312 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
313 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
314 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
315 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
316 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
317 h2c->state.handler = hc->proxy_protocol ? ngx_http_v2_state_proxy_protocol |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
318 : ngx_http_v2_state_preface; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
319 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
320 ngx_queue_init(&h2c->waiting); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
321 ngx_queue_init(&h2c->dependencies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
322 ngx_queue_init(&h2c->closed); |
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 c->data = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
325 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
326 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
327 c->write->handler = ngx_http_v2_write_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
328 |
7783
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
329 if (!rev->timer_set) { |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
330 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
|
331 ngx_http_core_module); |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
332 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
|
333 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
334 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
335 c->idle = 1; |
7769
0a5687a458de
HTTP/2: fixed reusing connections with active requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7768
diff
changeset
|
336 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
|
337 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
338 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
339 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
340 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
341 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
342 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
343 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
|
344 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
345 u_char *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
346 size_t available; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
347 ssize_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
348 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
349 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
350 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
351 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
352 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
353 h2c = c->data; |
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 if (rev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
356 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
|
357 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
|
358 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
361 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
|
362 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
363 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
364 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
365 if (c->close) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
366 c->close = 0; |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
367 |
7571
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
368 if (c->error) { |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
369 ngx_http_v2_finalize_connection(h2c, 0); |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
370 return; |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
371 } |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
372 |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
373 if (!h2c->processing && !h2c->pushing) { |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
374 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
|
375 return; |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
376 } |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
377 |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
378 if (!h2c->goaway) { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
379 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
380 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
381 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
|
382 == NGX_ERROR) |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
383 { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
384 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
|
385 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
386 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
387 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
388 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
|
389 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
|
390 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
391 } |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
392 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
393 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
394 h2c->blocked = 0; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
395 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
396 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
397 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
398 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
399 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
|
400 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
401 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
402 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
|
403 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
404 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
405 p = h2mcf->recv_buffer; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
406 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
407 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
|
408 end = p + h2c->state.buffer_used; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
409 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
410 n = c->recv(c, end, available); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
411 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
412 if (n == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
413 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
414 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
415 |
7201 | 416 if (n == 0 |
417 && (h2c->state.incomplete || h2c->processing || h2c->pushing)) | |
418 { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
419 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
|
420 "client prematurely closed connection"); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
423 if (n == 0 || n == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
424 c->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
425 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
426 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
427 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
428 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
429 end += n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
430 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
431 h2c->state.buffer_used = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
432 h2c->state.incomplete = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
433 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
434 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
435 p = h2c->state.handler(h2c, p, end); |
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 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
438 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
439 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
440 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
441 } while (p != end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
442 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
443 h2c->total_bytes += n; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
444 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
445 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
|
446 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
|
447 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
|
448 return; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
449 } |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
450 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
451 } while (rev->ready); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
452 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
453 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
|
454 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
|
455 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
456 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
457 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
458 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
|
459 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
460 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
461 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
462 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
463 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
464 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
465 ngx_http_v2_handle_connection(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
466 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
469 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
470 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
|
471 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
472 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
473 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
474 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
475 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
476 c = wev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
477 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
478 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
479 if (wev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
480 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
|
481 "http2 write event timed out"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
482 c->error = 1; |
7695
d57f15922ca3
HTTP/2: fixed c->timedout flag on timed out connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7673
diff
changeset
|
483 c->timedout = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
484 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
485 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
488 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
|
489 |
6639
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
490 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
|
491 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
492 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
|
493 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
|
494 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
495 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
496 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
|
497 return; |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
498 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
499 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
500 h2c->blocked = 1; |
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 rc = ngx_http_v2_send_output_queue(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
503 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
504 if (rc == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
505 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
506 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
507 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
508 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
509 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
510 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
511 if (rc == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
512 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
513 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
514 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
515 ngx_http_v2_handle_connection(h2c); |
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 |
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 ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
520 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
|
521 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
522 int tcp_nodelay; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
523 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
524 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
525 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
526 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
|
527 ngx_http_core_loc_conf_t *clcf; |
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 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
|
530 wev = c->write; |
6246
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 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
|
533 goto error; |
d6cf51af8a3d
HTTP/2: fixed possible alert about left open socket on shutdown.
Ruslan Ermilov <ru@nginx.com>
parents:
7569
diff
changeset
|
534 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
535 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
536 if (!wev->ready) { |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
537 return NGX_AGAIN; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
538 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
539 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
540 cl = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
542 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
543 for (frame = h2c->last_out; frame; frame = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
544 frame->last->next = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
545 cl = frame->first; |
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 fn = frame->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
548 frame->next = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
549 out = frame; |
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 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
|
552 "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
|
553 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
554 out->blocked, out->length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
555 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
556 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
557 cl = c->send_chain(c, cl, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
559 if (cl == NGX_CHAIN_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
560 goto error; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
563 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
|
564 ngx_http_core_module); |
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 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
|
567 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
568 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
569 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
570 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
571 if (ngx_tcp_push(c->fd) == -1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
572 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
|
573 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
577 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
|
578 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
579 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
580 tcp_nodelay = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6989
diff
changeset
|
583 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
|
584 goto error; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
585 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
586 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
588 fn = out->next; |
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 if (out->handler(h2c, out) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
591 out->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
592 break; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
595 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
|
596 "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
|
597 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
598 out->blocked, out->length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
599 } |
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 frame = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
602 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
603 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
604 fn = out->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
605 out->next = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
606 frame = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
607 } |
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 h2c->last_out = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
610 |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
611 if (!wev->ready) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
612 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
|
613 return NGX_AGAIN; |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
614 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
615 |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
616 if (wev->timer_set) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
617 ngx_del_timer(wev); |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
618 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
619 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
620 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
621 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
622 error: |
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 c->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
625 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
626 if (!h2c->blocked) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
627 ngx_post_event(wev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
628 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
629 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
630 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
631 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
632 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
633 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
634 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
635 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
|
636 { |
7771
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
637 ngx_int_t rc; |
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
638 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
|
639 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
640 |
7201 | 641 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
|
642 return; |
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 c = h2c->connection; |
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 if (c->error) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
648 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
649 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
650 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
651 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
652 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
|
653 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
|
654 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
655 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
|
656 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
657 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
|
658 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
659 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
|
660 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
|
661 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
662 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
663 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
664 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
|
665 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
666 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
667 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
668 /* rc == NGX_OK */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
669 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
670 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
671 if (h2c->goaway) { |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
672 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
|
673 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
674 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
675 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
676 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
|
677 ngx_http_core_module); |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
678 |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
679 if (!c->read->timer_set) { |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
680 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
|
681 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
682 |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
683 ngx_reusable_connection(c, 1); |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
684 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
685 if (h2c->state.incomplete) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
686 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
687 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
688 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
689 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
690 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
691 h2c->pool = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
692 h2c->free_frames = NULL; |
7377 | 693 h2c->frames = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
694 h2c->free_fake_connections = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
695 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
696 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
697 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
698 ngx_ssl_free_buffer(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
699 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
700 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
701 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
702 c->destroyed = 1; |
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 c->write->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
705 c->read->handler = ngx_http_v2_idle_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
706 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
707 if (c->write->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
708 ngx_del_timer(c->write); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
709 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
712 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
713 static void |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
714 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
|
715 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
716 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
|
717 ngx_http_v2_connection_t *h2c; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
718 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
719 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
720 h2c = c->data; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
721 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
722 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
|
723 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
724 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
725 if (clcf->lingering_close == NGX_HTTP_LINGERING_OFF) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
726 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
727 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
728 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
729 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
730 if (h2c->lingering_time == 0) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
731 h2c->lingering_time = ngx_time() |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
732 + (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
|
733 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
734 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
735 #if (NGX_HTTP_SSL) |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
736 if (c->ssl) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
737 ngx_int_t rc; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
738 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
739 rc = ngx_ssl_shutdown(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
740 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
741 if (rc == NGX_ERROR) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
742 ngx_http_close_connection(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
743 return; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
744 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
745 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
746 if (rc == NGX_AGAIN) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
747 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
|
748 return; |
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 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
751 #endif |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
752 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
753 rev = c->read; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
754 rev->handler = ngx_http_v2_lingering_close_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
755 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
756 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
|
757 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
758 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
759 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
760 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
761 wev = c->write; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
762 wev->handler = ngx_http_empty_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
763 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
764 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
|
765 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
|
766 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
767 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
768 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
769 } |
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_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
772 ngx_connection_error(c, ngx_socket_errno, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
773 ngx_shutdown_socket_n " failed"); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
774 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
775 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
776 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
777 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
778 c->close = 0; |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
779 ngx_reusable_connection(c, 1); |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
780 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
781 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
|
782 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
783 if (rev->ready) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
784 ngx_http_v2_lingering_close_handler(rev); |
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 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
787 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
788 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
789 static void |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
790 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
|
791 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
792 ssize_t n; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
793 ngx_msec_t timer; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
794 ngx_connection_t *c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
795 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
796 ngx_http_v2_connection_t *h2c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
797 u_char buffer[NGX_HTTP_LINGERING_BUFFER_SIZE]; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
798 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
799 c = rev->data; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
800 h2c = c->data; |
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 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
|
803 "http2 lingering close handler"); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
804 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
805 if (rev->timedout || c->close) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
806 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
807 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
808 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
809 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
810 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
|
811 if ((ngx_msec_int_t) timer <= 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
812 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
813 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
814 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
815 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
816 do { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
817 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
|
818 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
819 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
|
820 |
7765
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
821 if (n == NGX_AGAIN) { |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
822 break; |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
823 } |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
824 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
825 if (n == NGX_ERROR || n == 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
826 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
827 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
828 } |
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 } while (rev->ready); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
831 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
832 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
|
833 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
834 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
835 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
836 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
837 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
|
838 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
839 timer *= 1000; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
840 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
841 if (timer > clcf->lingering_timeout) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
842 timer = clcf->lingering_timeout; |
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 ngx_add_timer(rev, timer); |
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 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
848 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
849 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
850 ngx_http_v2_state_proxy_protocol(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
|
851 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
852 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
853 ngx_log_t *log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
854 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
855 log = h2c->connection->log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
856 log->action = "reading PROXY protocol"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
857 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
858 pos = ngx_proxy_protocol_read(h2c->connection, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
859 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
860 log->action = "processing HTTP/2 connection"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
861 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
862 if (pos == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
863 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
|
864 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
865 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
866 return ngx_http_v2_state_preface(h2c, pos, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
867 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
868 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
871 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
|
872 u_char *end) |
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 static const u_char preface[] = "PRI * HTTP/2.0\r\n"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
875 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
876 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
877 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
|
878 } |
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 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
|
881 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
|
882 "invalid connection preface"); |
6246
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 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
|
885 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
886 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
887 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
|
888 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
889 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
892 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
|
893 u_char *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 static const u_char preface[] = "\r\nSM\r\n\r\n"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
896 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
897 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
898 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
|
899 ngx_http_v2_state_preface_end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
900 } |
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 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
|
903 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
|
904 "invalid connection preface"); |
6246
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_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); |
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 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
|
910 "http2 preface verified"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
911 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
912 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
|
913 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
917 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
|
918 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 uint32_t head; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
920 ngx_uint_t type; |
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 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
|
923 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
|
924 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
925 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
926 head = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
927 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
928 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
|
929 h2c->state.flags = pos[4]; |
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 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
|
932 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
933 pos += NGX_HTTP_V2_FRAME_HEADER_SIZE; |
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 type = ngx_http_v2_parse_type(head); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
936 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
937 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
|
938 "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
|
939 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
|
940 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
941 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
|
942 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
|
943 "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
|
944 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
|
945 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
946 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
947 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
|
948 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
949 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
950 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
951 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
952 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
|
953 { |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
954 size_t size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
955 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
956 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
957 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
958 size = h2c->state.length; |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
959 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
960 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
|
961 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
962 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
963 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
|
964 "client sent padded DATA frame " |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
965 "with incorrect length: 0"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
966 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
967 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
|
968 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
969 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
970 if (end - pos == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
971 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
|
972 ngx_http_v2_state_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
973 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
974 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
975 h2c->state.padding = *pos++; |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
976 |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
977 if (h2c->state.padding >= size) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
978 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
|
979 "client sent padded DATA frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
980 "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
|
981 size, h2c->state.padding); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
982 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
983 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
|
984 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
985 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
986 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
987 h2c->state.length -= 1 + h2c->state.padding; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
988 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
989 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
990 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
|
991 "http2 DATA frame"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
992 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
993 if (h2c->state.sid == 0) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
994 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
|
995 "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
|
996 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
997 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
|
998 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
999 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1000 if (size > h2c->recv_window) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1001 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
|
1002 "client violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1003 "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
|
1004 size, h2c->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1005 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1006 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
|
1007 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1008 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1009 h2c->recv_window -= size; |
6246
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 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
|
1012 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1013 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
|
1014 - h2c->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1018 NGX_HTTP_V2_INTERNAL_ERROR); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1021 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1022 } |
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 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
|
1025 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1026 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 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
|
1028 "unknown http2 stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1029 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1030 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
|
1031 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1032 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1033 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1034 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1035 if (size > stream->recv_window) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 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
|
1037 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1038 "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
|
1039 node->id, size, stream->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1040 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1041 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1042 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1043 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1046 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1048 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1049 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
|
1050 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1051 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1052 stream->recv_window -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1053 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1054 if (stream->no_flow_control |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1055 && 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
|
1056 { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1057 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
|
1058 NGX_HTTP_V2_MAX_WINDOW |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1059 - stream->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1060 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1063 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1064 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1065 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1066 stream->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1069 if (stream->in_closed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 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
|
1071 "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
|
1072 node->id); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1073 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1074 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 NGX_HTTP_V2_STREAM_CLOSED) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1076 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1079 NGX_HTTP_V2_INTERNAL_ERROR); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1082 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
|
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 h2c->state.stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1086 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1087 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
|
1088 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1089 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1090 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1091 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1092 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
|
1093 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1094 { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1095 size_t size, window; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1096 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1097 ngx_int_t rc; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1098 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
|
1099 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
|
1100 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
|
1101 ngx_http_v2_srv_conf_t *h2scf; |
6246
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 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1104 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1105 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1106 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
|
1107 } |
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 if (stream->skip_data) { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1110 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
|
1111 "skipping http2 DATA frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1112 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1113 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
|
1114 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1115 |
7561
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1116 r = stream->request; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1117 fc = r->connection; |
7561
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 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
|
1120 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
|
1121 "skipping http2 DATA frame"); |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1122 |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1123 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
|
1124 } |
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1125 |
7710
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1126 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
|
1127 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
|
1128 "skipping http2 DATA frame"); |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1129 |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1130 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
|
1131 } |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1132 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1133 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1134 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1135 if (size >= h2c->state.length) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1136 size = h2c->state.length; |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
1137 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
|
1138 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1139 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1140 h2c->payload_bytes += size; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1141 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1142 if (r->request_body) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1143 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
|
1144 stream->in_closed, 0); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1145 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1146 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
|
1147 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1148 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
|
1149 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1150 |
7922
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1151 if (rc == NGX_AGAIN |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1152 && !stream->no_flow_control |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1153 && !r->request_body_no_buffering) |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1154 { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1155 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
|
1156 |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1157 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
|
1158 buf->pos = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1159 buf->last = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1160 } |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
1161 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1162 window = buf->end - buf->last; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1163 window -= h2c->state.length - size; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1164 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1165 if (window < stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1166 ngx_log_error(NGX_LOG_ALERT, h2c->connection->log, 0, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1167 "http2 negative window update"); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1168 return ngx_http_v2_connection_error(h2c, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1169 NGX_HTTP_V2_INTERNAL_ERROR); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1170 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1171 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1172 if (window > stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1173 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
|
1174 window - stream->recv_window) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1175 == NGX_ERROR) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1176 { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1177 return ngx_http_v2_connection_error(h2c, |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1178 NGX_HTTP_V2_INTERNAL_ERROR); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1179 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1180 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1181 stream->recv_window = window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1182 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1183 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1184 |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1185 ngx_http_run_posted_requests(fc); |
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1186 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1187 } else if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1188 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1189 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1190 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1191 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
|
1192 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1193 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
|
1194 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1195 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
|
1196 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
|
1197 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1198 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1199 stream->preread = buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1200 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1201 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1202 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
|
1203 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
|
1204 "http2 preread buffer overflow"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1205 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
|
1206 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
|
1207 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1208 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1209 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
|
1210 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1211 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1212 pos += size; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1213 h2c->state.length -= size; |
6246
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) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1216 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
|
1217 ngx_http_v2_state_read_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1218 } |
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 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1221 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
|
1222 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1223 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1224 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
|
1225 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1228 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1229 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
|
1230 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1231 { |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1232 size_t size; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1233 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
|
1234 weight; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1235 ngx_uint_t status; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1241 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1242 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
|
1243 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
|
1244 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1245 size = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1246 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1247 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1248 size++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1249 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1250 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1251 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1252 size += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1253 } |
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 if (h2c->state.length < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1256 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
|
1257 "client sent HEADERS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1258 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1259 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1260 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
|
1261 } |
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 (h2c->state.length == size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1264 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
|
1265 "client sent HEADERS frame with empty header block"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1266 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1267 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
|
1268 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1269 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1270 if (h2c->goaway) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1271 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
|
1272 "skipping http2 HEADERS frame"); |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1273 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
|
1274 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1275 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1276 if ((size_t) (end - pos) < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1277 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
|
1278 ngx_http_v2_state_headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1279 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1280 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1281 h2c->state.length -= size; |
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 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1284 h2c->state.padding = *pos++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1285 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1286 if (h2c->state.padding > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1287 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
|
1288 "client sent padded HEADERS frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1289 "with incorrect length: %uz, padding: %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1290 h2c->state.length, h2c->state.padding); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1291 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
1292 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
|
1293 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1294 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1295 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1296 h2c->state.length -= h2c->state.padding; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1297 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1298 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1299 depend = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1300 excl = 0; |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1301 weight = NGX_HTTP_V2_DEFAULT_WEIGHT; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1302 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1303 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1304 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1305 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1306 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1307 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1308 weight = pos[4] + 1; |
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 pos += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1311 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1312 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1313 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
|
1314 "http2 HEADERS frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1315 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1316 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1317 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1318 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
|
1319 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
|
1320 "client sent HEADERS frame with incorrect identifier " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1321 "%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
|
1322 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1323 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
|
1324 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1325 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1326 if (depend == h2c->state.sid) { |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1327 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
|
1328 "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
|
1329 "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
|
1330 |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1331 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
|
1332 } |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1333 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1334 h2c->last_sid = h2c->state.sid; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1335 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1336 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
|
1337 if (h2c->state.pool == NULL) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1338 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
|
1339 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1340 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1341 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
|
1342 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
|
1343 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1344 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
|
1345 * 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
|
1346 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1347 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
|
1348 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1349 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1350 if (h2c->processing >= h2scf->concurrent_streams) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1351 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
|
1352 "concurrent streams exceeded %ui", h2c->processing); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1353 |
6513
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1354 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
|
1355 goto rst_stream; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1356 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1357 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1358 if (!h2c->settings_ack |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1359 && !(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
|
1360 && 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
|
1361 { |
6516
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1362 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
|
1363 "client sent stream with data " |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1364 "before settings were acknowledged"); |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1365 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1366 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
|
1367 goto rst_stream; |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1368 } |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1369 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1370 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
|
1371 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1372 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1373 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
|
1374 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1375 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1376 if (node->parent) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1377 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1378 h2c->closed_nodes--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1379 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1380 |
7201 | 1381 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
|
1382 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1383 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
|
1384 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1385 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1386 h2c->state.stream = stream; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1387 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1388 stream->pool = h2c->state.pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1389 h2c->state.keep_pool = 1; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1390 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1391 stream->request->request_length = h2c->state.length; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1392 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1393 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
|
1394 stream->node = node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1395 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1396 node->stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1397 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1398 if (priority || node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1399 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1400 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
|
1401 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1402 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1403 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
|
1404 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1405 |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1406 if (clcf->keepalive_timeout == 0 |
7820
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1407 || h2c->connection->requests >= clcf->keepalive_requests |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1408 || ngx_current_msec - h2c->connection->start_time |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1409 > clcf->keepalive_time) |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1410 { |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1411 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1412 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1413 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
|
1414 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
|
1415 NGX_HTTP_V2_INTERNAL_ERROR); |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1416 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1417 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1418 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1419 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
|
1420 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1421 rst_stream: |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1422 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1423 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
|
1424 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
|
1425 } |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1426 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1427 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
|
1428 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1429 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1432 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
|
1433 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1434 { |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1435 u_char ch; |
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1436 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
|
1437 ngx_uint_t indexed, size_update, prefix; |
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 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1440 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
|
1441 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1442 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1443 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1444 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
|
1445 && 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
|
1446 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1447 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
|
1448 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
|
1449 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1450 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1451 size_update = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1452 indexed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1453 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1454 ch = *pos; |
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 if (ch >= (1 << 7)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1457 /* indexed header field */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1458 indexed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1459 prefix = ngx_http_v2_prefix(7); |
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 } else if (ch >= (1 << 6)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1462 /* literal header field with incremental indexing */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1463 h2c->state.index = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1464 prefix = ngx_http_v2_prefix(6); |
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 } else if (ch >= (1 << 5)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1467 /* dynamic table size update */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1468 size_update = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1469 prefix = ngx_http_v2_prefix(5); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1470 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1471 } else if (ch >= (1 << 4)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1472 /* literal header field never indexed */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1473 prefix = ngx_http_v2_prefix(4); |
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 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1476 /* 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
|
1477 prefix = ngx_http_v2_prefix(4); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1478 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1479 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1480 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
|
1481 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1482 if (value < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1483 if (value == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1484 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
|
1485 ngx_http_v2_state_header_block); |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1488 if (value == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1489 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
|
1490 "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
|
1491 size_update ? "size update" : "header index"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1492 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1493 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
|
1494 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1495 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1496 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
|
1497 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1498 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1499 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
|
1500 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1501 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1502 if (indexed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1503 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
|
1504 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
|
1505 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1506 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1507 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
|
1508 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1509 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1510 if (size_update) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1511 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
|
1512 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
|
1513 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1514 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1515 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
|
1516 } |
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 if (value == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1519 h2c->state.parse_name = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1520 |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1521 } 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
|
1522 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
|
1523 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1524 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1525 h2c->state.parse_value = 1; |
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 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
|
1528 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1529 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1530 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1531 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1532 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
|
1533 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1534 { |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1535 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
|
1536 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
|
1537 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
|
1538 ngx_http_core_srv_conf_t *cscf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1539 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1540 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
|
1541 && 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
|
1542 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1543 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
|
1544 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
|
1545 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1546 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1547 if (h2c->state.length < 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1548 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
|
1549 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1550 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1551 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
|
1552 } |
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 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1555 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
|
1556 ngx_http_v2_state_field_len); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1557 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1558 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1559 huff = *pos >> 7; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1560 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
|
1561 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1562 if (len < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1563 if (len == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1564 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
|
1565 ngx_http_v2_state_field_len); |
6246
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 if (len == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1569 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
|
1570 "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
|
1571 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1572 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
|
1573 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1574 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1575 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
|
1576 "client sent header block with incorrect length"); |
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 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
|
1579 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1580 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1581 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
|
1582 "http2 %s string, len:%i", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1583 huff ? "encoded" : "raw", len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1584 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1585 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
|
1586 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
|
1587 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1588 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
|
1589 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
|
1590 "client sent too large header field"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1591 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1592 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
|
1593 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1594 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1595 h2c->state.field_rest = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1596 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1597 if (h2c->state.stream == NULL && !h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1598 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
|
1599 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1600 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1601 alloc = (huff ? len * 8 / 5 : len) + 1; |
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 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
|
1604 if (h2c->state.field_start == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1605 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
|
1606 } |
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 h2c->state.field_end = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1609 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1610 if (huff) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1611 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
|
1612 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1613 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1614 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
|
1615 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1616 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1617 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1618 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1619 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
|
1620 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1621 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1622 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1623 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1624 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1625 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1626 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1627 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1628 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1629 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1630 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
|
1631 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1632 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1633 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1634 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1635 h2c->state.field_rest -= size; |
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 if (ngx_http_v2_huff_decode(&h2c->state.field_state, pos, size, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1638 &h2c->state.field_end, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1639 h2c->state.field_rest == 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1640 h2c->connection->log) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1641 != NGX_OK) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1642 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1643 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
|
1644 "client sent invalid encoded header field"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1645 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1646 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
|
1647 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1648 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1649 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1650 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1651 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
|
1652 *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
|
1653 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
|
1654 } |
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.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1657 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
|
1658 ngx_http_v2_state_field_huff); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1659 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1660 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1661 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
|
1662 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
|
1663 "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
|
1664 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1665 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
|
1666 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1667 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1668 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
|
1669 ngx_http_v2_state_field_huff); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1670 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1671 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1672 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1673 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1674 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
|
1675 u_char *end) |
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 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1678 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1679 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1680 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1681 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1682 size = h2c->state.field_rest; |
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 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1685 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
|
1686 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1687 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1688 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1689 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1690 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1691 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1692 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
|
1693 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1694 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1695 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1696 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
|
1697 *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
|
1698 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
|
1699 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1700 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1701 if (h2c->state.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1702 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
|
1703 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1704 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1705 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1706 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
|
1707 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
|
1708 "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
|
1709 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1710 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
|
1711 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1712 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1713 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
|
1714 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1715 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1716 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1719 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
|
1720 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1721 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1722 size_t size; |
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 = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1725 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1726 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1727 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1728 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1729 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1730 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
|
1731 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1732 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1733 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1734 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1735 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1736 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1737 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1738 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1739 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
|
1740 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
|
1741 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1742 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1743 if (h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1744 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
|
1745 ngx_http_v2_state_field_skip); |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1746 } |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1747 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1748 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
|
1749 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
|
1750 "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
|
1751 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1752 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
|
1753 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1754 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1755 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
|
1756 ngx_http_v2_state_field_skip); |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1759 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1760 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1761 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
|
1762 u_char *end) |
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 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1765 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1766 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1767 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1768 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1769 ngx_http_v2_header_t *header; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1770 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1771 ngx_http_core_main_conf_t *cmcf; |
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 static ngx_str_t cookie = ngx_string("cookie"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1774 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1775 header = &h2c->state.header; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1776 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1777 if (h2c->state.parse_name) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1778 h2c->state.parse_name = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1779 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1780 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
|
1781 header->name.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1782 |
7547
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1783 if (header->name.len == 0) { |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1784 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
|
1785 "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
|
1786 |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1787 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
|
1788 NGX_HTTP_V2_PROTOCOL_ERROR); |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1789 } |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1790 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1791 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
|
1792 } |
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 if (h2c->state.parse_value) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1795 h2c->state.parse_value = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1796 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1797 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
|
1798 header->value.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1799 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1800 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1801 len = header->name.len + header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1802 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1803 if (len > h2c->state.header_limit) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1804 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
|
1805 "client sent too large header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1806 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1807 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
|
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 h2c->state.header_limit -= len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1811 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1812 if (h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1813 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
|
1814 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1815 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 h2c->state.index = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1819 } |
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 (h2c->state.stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1822 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
|
1823 } |
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 r = h2c->state.stream->request; |
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 /* TODO Optimization: validate headers while parsing. */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1828 if (ngx_http_v2_validate_header(r, header) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1829 if (ngx_http_v2_terminate_stream(h2c, h2c->state.stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1830 NGX_HTTP_V2_PROTOCOL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1831 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1832 { |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1837 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1838 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1839 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1840 if (header->name.data[0] == ':') { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1841 rc = ngx_http_v2_pseudo_header(r, header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1842 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1843 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
|
1844 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
|
1845 "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
|
1846 &header->name, &header->value); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1847 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1848 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
|
1849 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1850 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1851 if (rc == NGX_ABORT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1852 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1853 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1854 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1855 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
|
1856 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
|
1857 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1858 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1859 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1860 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
|
1861 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1862 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1863 if (r->invalid_header) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1864 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
|
1865 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1866 if (cscf->ignore_invalid_headers) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1867 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
|
1868 "client sent invalid header: \"%V\"", &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1869 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1870 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
|
1871 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1872 } |
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 if (header->name.len == cookie.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1875 && 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
|
1876 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1877 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
|
1878 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1879 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1880 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1881 |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1882 } else { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1883 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
|
1884 if (h == NULL) { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1885 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
|
1886 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
|
1887 } |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1888 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1889 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
|
1890 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
|
1891 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1892 /* |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1893 * TODO Optimization: precalculate hash |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1894 * 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
|
1895 */ |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1896 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
|
1897 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1898 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
|
1899 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
|
1900 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1901 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
|
1902 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1903 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
|
1904 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1905 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
|
1906 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
|
1907 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1908 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
|
1909 goto error; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1910 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1911 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1912 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1913 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
|
1914 "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
|
1915 &header->name, &header->value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1916 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1917 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
|
1918 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1919 error: |
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 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1922 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1923 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
|
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1927 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1928 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
|
1929 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1930 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1931 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1932 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1933 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
|
1934 if (end - pos > 0) { |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1935 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
|
1936 return pos; |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1937 } |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1938 |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1939 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
|
1940 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1941 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1942 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1943 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
|
1944 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
|
1945 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
|
1946 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1947 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1948 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1949 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1950 if (stream) { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1951 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
|
1952 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1953 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1954 if (!h2c->state.keep_pool) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1955 ngx_destroy_pool(h2c->state.pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1956 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1957 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1958 h2c->state.pool = NULL; |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1959 h2c->state.keep_pool = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1960 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1961 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1962 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
|
1963 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1964 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1965 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
|
1966 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1967 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1968 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1969 static u_char * |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1970 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
|
1971 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
|
1972 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1973 u_char *p; |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1974 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
|
1975 uint32_t head; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1976 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1977 len = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1978 |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1979 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
|
1980 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
|
1981 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1982 h2c->state.padding -= skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1983 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1984 p = pos; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1985 pos += skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1986 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
|
1987 } |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1988 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1989 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
|
1990 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
|
1991 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1992 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1993 p = pos + len; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1994 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1995 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
|
1996 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1997 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
|
1998 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
|
1999 "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
|
2000 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2001 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
|
2002 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2003 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2004 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
|
2005 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2006 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
|
2007 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
|
2008 "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
|
2009 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2010 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
|
2011 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2012 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2013 p = pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2014 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
|
2015 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2016 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
|
2017 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2018 len = ngx_http_v2_parse_length(head); |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2019 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2020 h2c->state.length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2021 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2022 if (h2c->state.stream) { |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2023 h2c->state.stream->request->request_length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2024 } |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
2025 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2026 h2c->state.handler = handler; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2027 return pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2028 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2029 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2030 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2031 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2032 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
|
2033 u_char *end) |
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 ngx_uint_t depend, dependency, excl, weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2036 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2037 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2038 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
|
2039 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
|
2040 "client sent PRIORITY frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2041 h2c->state.length); |
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 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
|
2044 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2045 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2046 if (--h2c->priority_limit == 0) { |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2047 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
|
2048 "client sent too many PRIORITY frames"); |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2049 |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2050 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
|
2051 } |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
2052 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2053 if (end - pos < NGX_HTTP_V2_PRIORITY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2054 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
|
2055 ngx_http_v2_state_priority); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2056 } |
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 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2059 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2060 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2061 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2062 weight = pos[4] + 1; |
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 pos += NGX_HTTP_V2_PRIORITY_SIZE; |
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 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
|
2067 "http2 PRIORITY frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2068 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2069 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2070 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2071 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2072 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
|
2073 "client sent PRIORITY frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2074 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2075 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
|
2076 } |
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 (depend == h2c->state.sid) { |
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 PRIORITY frame for stream %ui " |
6284
66ee1c5cb6aa
HTTP/2: fixed spelling.
Valentin Bartenev <vbart@nginx.com>
parents:
6280
diff
changeset
|
2081 "with incorrect dependency", h2c->state.sid); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2082 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
2083 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
|
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 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
|
2087 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2088 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2089 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
|
2090 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2091 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2092 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2093 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2094 if (node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2095 if (node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2096 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2097 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2098 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2099 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2100 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2101 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2102 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2103 } |
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 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
|
2106 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2107 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
|
2108 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2109 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2110 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2111 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2112 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
|
2113 u_char *end) |
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 ngx_uint_t status; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2116 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2117 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2118 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2119 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2120 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2121 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
|
2122 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
|
2123 "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
|
2124 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2125 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2126 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
|
2127 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2128 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2129 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
|
2130 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
|
2131 ngx_http_v2_state_rst_stream); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2132 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2133 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2134 status = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2135 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2136 pos += NGX_HTTP_V2_RST_STREAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2137 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2138 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
|
2139 "http2 RST_STREAM frame, sid:%ui status:%ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2140 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2141 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2142 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2143 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
|
2144 "client sent RST_STREAM frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2145 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2146 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
|
2147 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2148 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2149 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
|
2150 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2151 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2152 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
|
2153 "unknown http2 stream"); |
6246
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 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
|
2156 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2157 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2158 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2159 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2160 stream->in_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2161 stream->out_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2162 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2163 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2164 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2165 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2166 switch (status) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2167 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2168 case NGX_HTTP_V2_CANCEL: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2169 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
|
2170 "client canceled stream %ui", h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2171 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2172 |
7201 | 2173 case NGX_HTTP_V2_REFUSED_STREAM: |
2174 ngx_log_error(NGX_LOG_INFO, fc->log, 0, | |
2175 "client refused stream %ui", h2c->state.sid); | |
2176 break; | |
2177 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2178 case NGX_HTTP_V2_INTERNAL_ERROR: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2179 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
|
2180 "client terminated stream %ui due to internal error", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2181 h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2182 break; |
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 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2185 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
|
2186 "client terminated stream %ui with status %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2187 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2188 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2189 } |
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 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2192 ev->handler(ev); |
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 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
|
2195 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2196 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2197 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2198 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2199 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
|
2200 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2201 { |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2202 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
|
2203 "http2 SETTINGS frame"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2204 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2205 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2206 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
|
2207 "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
|
2208 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2209 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
|
2210 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2211 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2212 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
|
2213 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2214 if (h2c->state.length != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2215 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
|
2216 "client sent SETTINGS frame with the ACK flag " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2217 "and nonzero length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2218 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2219 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
|
2220 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2221 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
2222 h2c->settings_ack = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2223 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2224 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
|
2225 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2226 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2227 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
|
2228 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
|
2229 "client sent SETTINGS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2230 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2231 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2232 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
|
2233 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2234 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2235 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
|
2236 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2237 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2238 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2239 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2240 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
|
2241 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2242 { |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2243 ssize_t window_delta; |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2244 ngx_uint_t id, value; |
7201 | 2245 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
|
2246 ngx_http_v2_out_frame_t *frame; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2247 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2248 window_delta = 0; |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2249 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2250 while (h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2251 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
|
2252 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
|
2253 ngx_http_v2_state_settings_params); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2254 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2255 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2256 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
|
2257 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2258 id = ngx_http_v2_parse_uint16(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2259 value = ngx_http_v2_parse_uint32(&pos[2]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2260 |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2261 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
|
2262 "http2 setting %ui:%ui", id, value); |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2263 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2264 switch (id) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2265 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2266 case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2267 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2268 if (value > NGX_HTTP_V2_MAX_WINDOW) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2269 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
|
2270 "client sent SETTINGS frame with incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2271 "INITIAL_WINDOW_SIZE value %ui", value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2272 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2273 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2274 NGX_HTTP_V2_FLOW_CTRL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2275 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2276 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2277 window_delta = value - h2c->init_window; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2278 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2279 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2280 case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING: |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
2281 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2282 if (value > NGX_HTTP_V2_MAX_FRAME_SIZE |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2283 || value < NGX_HTTP_V2_DEFAULT_FRAME_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 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
|
2286 "client sent SETTINGS frame with incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2287 "MAX_FRAME_SIZE value %ui", value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2288 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2289 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2290 NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2291 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2292 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2293 h2c->frame_size = value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2294 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2295 |
7201 | 2296 case NGX_HTTP_V2_ENABLE_PUSH_SETTING: |
2297 | |
2298 if (value > 1) { | |
2299 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
2300 "client sent SETTINGS frame with incorrect " | |
2301 "ENABLE_PUSH value %ui", value); | |
2302 | |
2303 return ngx_http_v2_connection_error(h2c, | |
2304 NGX_HTTP_V2_PROTOCOL_ERROR); | |
2305 } | |
2306 | |
2307 h2c->push_disabled = !value; | |
2308 break; | |
2309 | |
2310 case NGX_HTTP_V2_MAX_STREAMS_SETTING: | |
2311 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, | |
2312 ngx_http_v2_module); | |
2313 | |
2314 h2c->concurrent_pushes = ngx_min(value, h2scf->concurrent_pushes); | |
2315 break; | |
2316 | |
7335
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2317 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
|
2318 |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2319 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
|
2320 break; |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2321 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2322 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2323 break; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2326 pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2327 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2328 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2329 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
|
2330 NGX_HTTP_V2_SETTINGS_FRAME, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2331 NGX_HTTP_V2_ACK_FLAG, 0); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2332 if (frame == NULL) { |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2333 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
|
2334 } |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2335 |
7025
7206c3630310
HTTP/2: don't send SETTINGS ACK before already queued DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
7024
diff
changeset
|
2336 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
|
2337 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2338 if (window_delta) { |
7190
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2339 h2c->init_window += window_delta; |
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2340 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2341 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
|
2342 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
|
2343 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
|
2344 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2345 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2346 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2347 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
|
2348 } |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2352 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
|
2353 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2354 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2355 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
|
2356 "client sent PUSH_PROMISE frame"); |
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 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
|
2359 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2360 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2363 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
|
2364 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2365 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2366 ngx_http_v2_out_frame_t *frame; |
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 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
|
2369 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
|
2370 "client sent PING frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2371 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2372 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2373 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
|
2374 } |
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 (end - pos < NGX_HTTP_V2_PING_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2377 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
|
2378 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2379 |
7241
190591ab0d76
HTTP/2: improved frame info debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7229
diff
changeset
|
2380 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
|
2381 "http2 PING frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2382 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2383 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2384 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
|
2385 "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
|
2386 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2387 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
|
2388 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2389 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2390 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
|
2391 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
|
2392 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2393 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2394 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
|
2395 NGX_HTTP_V2_PING_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2396 NGX_HTTP_V2_ACK_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2397 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2398 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
|
2399 } |
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 buf = frame->first->buf; |
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 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
|
2404 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2405 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2406 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2407 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
|
2408 } |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2412 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
|
2413 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2414 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2415 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2416 ngx_uint_t last_sid, error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2417 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2418 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2419 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
|
2420 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
|
2421 "client sent GOAWAY frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2422 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2423 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2424 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
|
2425 } |
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 if (end - pos < NGX_HTTP_V2_GOAWAY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2428 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
|
2429 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2430 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2431 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2432 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
|
2433 "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
|
2434 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2435 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
|
2436 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2437 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2438 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2439 h2c->state.length -= NGX_HTTP_V2_GOAWAY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2440 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2441 last_sid = ngx_http_v2_parse_sid(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2442 error = ngx_http_v2_parse_uint32(&pos[4]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2443 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2444 pos += NGX_HTTP_V2_GOAWAY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2445 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2446 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
|
2447 "http2 GOAWAY frame: last sid %ui, error %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2448 last_sid, error); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2449 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2450 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2451 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
|
2452 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2455 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2456 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
|
2457 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2458 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2459 size_t window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2460 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2461 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2462 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2463 ngx_http_v2_stream_t *stream; |
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 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
|
2466 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
|
2467 "client sent WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2468 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2469 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2470 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
|
2471 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2472 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2473 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
|
2474 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
|
2475 ngx_http_v2_state_window_update); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2476 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2477 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2478 window = ngx_http_v2_parse_window(pos); |
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 pos += NGX_HTTP_V2_WINDOW_UPDATE_SIZE; |
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 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
|
2483 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2484 h2c->state.sid, window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2485 |
6988
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2486 if (window == 0) { |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2487 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
|
2488 "client sent WINDOW_UPDATE frame " |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2489 "with incorrect window increment 0"); |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2490 |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2491 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
|
2492 } |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2493 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2494 if (h2c->state.sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2495 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
|
2496 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2497 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2498 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
|
2499 "unknown http2 stream"); |
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 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
|
2502 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2503 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2504 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2505 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2506 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
|
2507 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2508 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
|
2509 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2510 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2511 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2512 "not allowed for window %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2513 h2c->state.sid, window, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2514 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2515 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2516 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2517 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2520 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2521 } |
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 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
|
2524 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2525 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2526 stream->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2527 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2528 if (stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2529 stream->exhausted = 0; |
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 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2532 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2533 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2534 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2535 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2536 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2537 wev->handler(wev); |
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 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
|
2542 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2543 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2544 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
|
2545 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
|
2546 "client violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2547 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2548 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2549 "not allowed for window %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2550 window, h2c->send_window); |
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 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
|
2553 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2554 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2555 h2c->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2556 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2557 while (!ngx_queue_empty(&h2c->waiting)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2558 q = ngx_queue_head(&h2c->waiting); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2559 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2560 ngx_queue_remove(q); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2561 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2562 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
|
2563 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
2564 stream->waiting = 0; |
6246
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 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2567 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2568 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2569 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2570 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2571 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2572 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2573 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2574 if (h2c->send_window == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2575 break; |
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 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2578 } |
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_complete(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_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
|
2586 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2587 { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2588 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
|
2589 "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
|
2590 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2591 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
|
2592 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2593 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2596 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
|
2597 u_char *end) |
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_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
|
2600 "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
|
2601 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2602 if (pos > end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2603 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
|
2604 "receive buffer overrun"); |
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 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
|
2607 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2608 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2609 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2610 h2c->state.handler = ngx_http_v2_state_head; |
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 return pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2613 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2614 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2617 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
|
2618 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2619 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2620 h2c->state.length += h2c->state.padding; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2621 h2c->state.padding = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2622 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2623 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
|
2624 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2625 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2628 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
|
2629 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2630 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2631 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2632 size = end - pos; |
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 if (size < h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2635 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
|
2636 "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
|
2637 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2638 h2c->state.length -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2639 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
|
2640 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2641 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2642 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
|
2643 "http2 frame skip %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2644 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2645 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
|
2646 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2647 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2648 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2649 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2650 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
|
2651 ngx_http_v2_handler_pt handler) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2652 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2653 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2654 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2655 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
|
2656 "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
|
2657 pos, end, handler); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2658 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2659 size = end - pos; |
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 if (size > NGX_HTTP_V2_STATE_BUFFER_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2662 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
|
2663 "state buffer overflow: %uz bytes required", size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2664 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2665 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
|
2666 } |
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 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
|
2669 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2670 h2c->state.buffer_used = size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2671 h2c->state.handler = handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2672 h2c->state.incomplete = 1; |
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 return end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2675 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2678 static u_char * |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2679 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
|
2680 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
|
2681 { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2682 ngx_event_t *rev; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2683 ngx_http_request_t *r; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2684 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
|
2685 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2686 if (h2c->state.stream) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2687 r = h2c->state.stream->request; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2688 rev = r->connection->read; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2689 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2690 if (!rev->timer_set) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2691 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
|
2692 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
|
2693 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2694 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2695 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2696 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
|
2697 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2698 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2699 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2700 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2701 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
|
2702 ngx_uint_t err) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2703 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2704 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
|
2705 "http2 state connection error"); |
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 ngx_http_v2_finalize_connection(h2c, err); |
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 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2710 } |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2714 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
|
2715 ngx_uint_t prefix) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2716 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2717 u_char *start, *p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2718 ngx_uint_t value, octet, shift; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2719 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2720 start = *pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2721 p = start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2722 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2723 value = *p++ & prefix; |
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 if (value != prefix) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2726 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2727 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2728 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2729 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2730 h2c->state.length--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2731 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2732 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2733 return value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2734 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2735 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2736 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
|
2737 end = start + NGX_HTTP_V2_INT_OCTETS; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2738 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2739 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2740 for (shift = 0; p != end; shift += 7) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2741 octet = *p++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2742 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2743 value += (octet & 0x7f) << shift; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2744 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2745 if (octet < 128) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2746 if ((size_t) (p - start) > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2747 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2748 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2749 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2750 h2c->state.length -= p - start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2751 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2752 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2753 return value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2754 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2755 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2756 |
6268
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2757 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
|
2758 return NGX_ERROR; |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2759 } |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2760 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2761 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
|
2762 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2763 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2764 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2765 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2766 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2767 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2768 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2769 ngx_http_v2_stream_t * |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2770 ngx_http_v2_push_stream(ngx_http_v2_stream_t *parent, ngx_str_t *path) |
7201 | 2771 { |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2772 ngx_int_t rc; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2773 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
|
2774 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
|
2775 ngx_uint_t index; |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2776 ngx_table_elt_t **h; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2777 ngx_connection_t *fc; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2778 ngx_http_request_t *r; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2779 ngx_http_v2_node_t *node; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2780 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
|
2781 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
|
2782 ngx_http_v2_connection_t *h2c; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2783 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
|
2784 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2785 h2c = parent->connection; |
7201 | 2786 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2787 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
|
2788 if (pool == NULL) { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2789 goto rst_stream; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2790 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2791 |
7201 | 2792 node = ngx_http_v2_get_node_by_id(h2c, h2c->last_push, 1); |
2793 | |
2794 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
|
2795 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
|
2796 goto rst_stream; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2797 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2798 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2799 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
|
2800 if (stream == NULL) { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2801 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2802 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
|
2803 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
|
2804 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
|
2805 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2806 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
|
2807 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
|
2808 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2809 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
|
2810 h2c->closed_nodes++; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2811 } |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2812 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2813 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
|
2814 goto rst_stream; |
7201 | 2815 } |
2816 | |
2817 if (node->parent) { | |
2818 ngx_queue_remove(&node->reuse); | |
2819 h2c->closed_nodes--; | |
2820 } | |
2821 | |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2822 stream->pool = pool; |
7201 | 2823 |
2824 r = stream->request; | |
2825 fc = r->connection; | |
2826 | |
2827 stream->in_closed = 1; | |
2828 stream->node = node; | |
2829 | |
2830 node->stream = stream; | |
2831 | |
2832 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | |
2833 "http2 push stream sid:%ui " | |
2834 "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
|
2835 h2c->last_push, parent->node->id); |
7201 | 2836 |
2837 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
|
2838 ngx_http_v2_set_dependency(h2c, node, parent->node->id, 0); |
7201 | 2839 |
2840 r->method_name = ngx_http_core_get_method; | |
2841 r->method = NGX_HTTP_GET; | |
2842 | |
7296
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2843 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
|
2844 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
|
2845 goto close; |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2846 } |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2847 |
8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
2848 r->schema.len = parent->request->schema.len; |
7201 | 2849 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2850 value.data = ngx_pstrdup(pool, path); |
7201 | 2851 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
|
2852 goto close; |
7201 | 2853 } |
2854 | |
2855 value.len = path->len; | |
2856 | |
2857 rc = ngx_http_v2_parse_path(r, &value); | |
2858 | |
2859 if (rc != NGX_OK) { | |
2860 goto error; | |
2861 } | |
2862 | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2863 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
|
2864 h = (ngx_table_elt_t **) |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2865 ((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
|
2866 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2867 if (*h == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2868 continue; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2869 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2870 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2871 value.len = (*h)->value.len; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2872 |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2873 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
|
2874 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
|
2875 goto close; |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2876 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2877 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2878 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
|
2879 value.data[value.len] = '\0'; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2880 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2881 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
|
2882 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2883 if (rc != NGX_OK) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2884 goto error; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2885 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2886 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2887 |
7201 | 2888 fc->write->handler = ngx_http_v2_run_request_handler; |
2889 ngx_post_event(fc->write, &ngx_posted_events); | |
2890 | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2891 return stream; |
7201 | 2892 |
2893 error: | |
2894 | |
2895 if (rc == NGX_ABORT) { | |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2896 /* 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
|
2897 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
|
2898 return NULL; |
7201 | 2899 } |
2900 | |
2901 if (rc == NGX_DECLINED) { | |
2902 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
|
2903 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
|
2904 return NULL; |
7201 | 2905 } |
2906 | |
7208
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2907 close: |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2908 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2909 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
|
2910 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2911 return NULL; |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2912 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2913 rst_stream: |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2914 |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2915 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
|
2916 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
|
2917 != NGX_OK) |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2918 { |
affeb6ef732c
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov <ru@nginx.com>
parents:
7207
diff
changeset
|
2919 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
|
2920 } |
7201 | 2921 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
2922 return NULL; |
7201 | 2923 } |
2924 | |
2925 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2926 static ngx_int_t |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2927 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
|
2928 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2929 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2930 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2931 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2932 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2933 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2934 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2935 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
|
2936 "http2 send SETTINGS frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2937 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2938 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
|
2939 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2940 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2941 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2942 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2943 cl = ngx_alloc_chain_link(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2944 if (cl == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2945 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2946 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2947 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2948 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
|
2949 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2950 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
|
2951 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2952 return NGX_ERROR; |
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 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2956 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2957 cl->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2958 cl->next = NULL; |
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 frame->first = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2961 frame->last = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2962 frame->handler = ngx_http_v2_settings_frame_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2963 frame->stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2964 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2965 frame->length = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2966 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2967 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2968 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2969 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
|
2970 NGX_HTTP_V2_SETTINGS_FRAME); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2971 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2972 *buf->last++ = NGX_HTTP_V2_NO_FLAG; |
6246
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 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
|
2975 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2976 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
|
2977 ngx_http_v2_module); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2978 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2979 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
|
2980 NGX_HTTP_V2_MAX_STREAMS_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2981 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
|
2982 h2scf->concurrent_streams); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2983 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2984 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
|
2985 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
|
2986 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
|
2987 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2988 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
|
2989 NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2990 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
|
2991 NGX_HTTP_V2_MAX_FRAME_SIZE); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2992 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2993 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2994 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2995 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2996 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2999 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3000 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
|
3001 ngx_http_v2_out_frame_t *frame) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3002 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3003 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3004 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3005 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3006 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3007 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3008 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3009 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3010 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3011 ngx_free_chain(h2c->pool, frame->first); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3012 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3013 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3014 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3015 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3016 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3017 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3018 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
|
3019 size_t window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3020 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3021 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3022 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3023 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3024 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
|
3025 "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
|
3026 sid, window); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3027 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3028 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
|
3029 NGX_HTTP_V2_WINDOW_UPDATE_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3030 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3031 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3032 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3033 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3034 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3035 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3036 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3037 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
|
3038 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3039 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3040 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3041 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3042 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3043 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3044 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3045 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3046 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
|
3047 ngx_uint_t status) |
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 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3050 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3051 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3052 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
|
3053 "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
|
3054 sid, status); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3055 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3056 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
|
3057 NGX_HTTP_V2_RST_STREAM_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3058 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3059 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3060 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3063 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3064 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3065 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
|
3066 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3067 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3068 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3069 return NGX_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3072 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3073 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3074 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
|
3075 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3076 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3077 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3078 |
6790
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3079 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
|
3080 "http2 send GOAWAY frame: last sid %ui, error %ui", |
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
3081 h2c->last_sid, status); |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
3082 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3083 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
|
3084 NGX_HTTP_V2_GOAWAY_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3085 NGX_HTTP_V2_NO_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3086 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3087 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3090 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3091 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3092 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
|
3093 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
|
3094 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3095 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3096 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3097 return NGX_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3100 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3101 static ngx_http_v2_out_frame_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3102 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
|
3103 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
|
3104 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3105 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3106 ngx_pool_t *pool; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3107 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3108 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3109 frame = h2c->free_frames; |
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 (frame) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3112 h2c->free_frames = frame->next; |
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 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3115 buf->pos = buf->start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3116 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3117 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3118 |
7377 | 3119 } else if (h2c->frames < 10000) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3120 pool = h2c->pool ? h2c->pool : h2c->connection->pool; |
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 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
|
3123 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3124 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3127 frame->first = ngx_alloc_chain_link(pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3128 if (frame->first == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3129 return NULL; |
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 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
|
3133 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3134 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3137 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3138 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3139 frame->first->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3140 frame->last = frame->first; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3141 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3142 frame->handler = ngx_http_v2_frame_handler; |
7377 | 3143 |
3144 h2c->frames++; | |
3145 | |
3146 } else { | |
3147 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
3148 "http2 flood detected"); | |
3149 | |
3150 h2c->connection->error = 1; | |
3151 return NULL; | |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3154 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3155 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
|
3156 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3157 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
|
3158 "requested control frame is too large: %uz", length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3159 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3160 } |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3161 #endif |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3162 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3163 frame->length = length; |
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 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
|
3166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3167 *buf->last++ = flags; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3168 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3169 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
|
3170 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3171 return frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3172 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3173 |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3176 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
|
3177 ngx_http_v2_out_frame_t *frame) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3178 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3179 ngx_buf_t *buf; |
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 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3182 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3183 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3184 return NGX_AGAIN; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3187 frame->next = h2c->free_frames; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3188 h2c->free_frames = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3189 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3190 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
|
3191 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3192 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3193 } |
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 static ngx_http_v2_stream_t * |
7201 | 3197 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
|
3198 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3199 ngx_log_t *log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3200 ngx_event_t *rev, *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3201 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3202 ngx_http_log_ctx_t *ctx; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3203 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3204 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
|
3205 ngx_http_v2_srv_conf_t *h2scf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3206 ngx_http_core_srv_conf_t *cscf; |
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 fc = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3209 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3210 if (fc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3211 h2c->free_fake_connections = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3212 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3213 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3214 wev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3215 log = fc->log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3216 ctx = log->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3217 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3218 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3219 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
|
3220 if (fc == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3221 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3222 } |
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 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
|
3225 if (rev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3226 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3229 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
|
3230 if (wev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3231 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3232 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3233 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3234 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
|
3235 if (log == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3236 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3237 } |
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 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
|
3240 if (ctx == 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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3244 ctx->connection = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3245 ctx->request = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3246 ctx->current_request = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3247 } |
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 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
|
3250 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3251 log->data = ctx; |
7201 | 3252 |
3253 if (push) { | |
3254 log->action = "processing pushed request headers"; | |
3255 | |
3256 } else { | |
3257 log->action = "reading client request headers"; | |
3258 } | |
6246
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 ngx_memzero(rev, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3261 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3262 rev->data = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3263 rev->ready = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3264 rev->handler = ngx_http_v2_close_stream_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3265 rev->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3266 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3267 ngx_memcpy(wev, rev, sizeof(ngx_event_t)); |
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 wev->write = 1; |
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 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
|
3272 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3273 fc->data = h2c->http_connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3274 fc->read = rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3275 fc->write = wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3276 fc->sent = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3277 fc->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3278 fc->buffered = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3279 fc->sndlowat = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3280 fc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3281 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3282 r = ngx_http_create_request(fc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3283 if (r == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3284 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3285 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3286 |
6256
9dfc4ba140f9
HTTP/2: fixed $server_protocol value (ticket #800).
Valentin Bartenev <vbart@nginx.com>
parents:
6249
diff
changeset
|
3287 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
|
3288 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3289 r->http_version = NGX_HTTP_VERSION_20; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3290 r->valid_location = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3291 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3292 fc->data = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3293 h2c->connection->requests++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3294 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3295 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
|
3296 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3297 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
|
3298 cscf->client_header_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3299 if (r->header_in == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3300 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
|
3301 return NULL; |
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 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
|
3305 sizeof(ngx_table_elt_t)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3306 != NGX_OK) |
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_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
|
3309 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3310 } |
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 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
|
3313 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3314 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
|
3315 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3316 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
|
3317 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3320 r->stream = stream; |
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 stream->request = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3323 stream->connection = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3324 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3325 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
|
3326 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3327 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
|
3328 stream->recv_window = h2scf->preread_size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3329 |
7201 | 3330 if (push) { |
3331 h2c->pushing++; | |
3332 | |
3333 } else { | |
3334 h2c->processing++; | |
3335 } | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3336 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3337 h2c->priority_limit += h2scf->concurrent_streams; |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3338 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3339 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
|
3340 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
|
3341 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3342 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3343 return stream; |
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 |
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 static ngx_http_v2_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3348 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
|
3349 ngx_uint_t alloc) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3350 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3351 ngx_uint_t index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3352 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3353 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3354 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3355 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
|
3356 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3357 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3358 index = ngx_http_v2_index(h2scf, sid); |
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 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
|
3361 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3362 if (node->id == sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3363 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3364 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3367 if (!alloc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3368 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3371 if (h2c->closed_nodes < 32) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3372 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
|
3373 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3374 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3375 } |
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 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3378 node = ngx_http_v2_get_closed_node(h2c); |
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 node->id = sid; |
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 ngx_queue_init(&node->children); |
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 node->index = h2c->streams_index[index]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3386 h2c->streams_index[index] = node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3387 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3388 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3389 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3390 |
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 static ngx_http_v2_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3393 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
|
3394 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3395 ngx_uint_t weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3396 ngx_queue_t *q, *children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3397 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
|
3398 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3399 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3400 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
|
3401 ngx_http_v2_module); |
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 h2c->closed_nodes--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3404 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3405 q = ngx_queue_head(&h2c->closed); |
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 ngx_queue_remove(q); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3408 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3409 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
|
3410 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3411 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
|
3412 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3413 for ( ;; ) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3414 n = *next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3415 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3416 if (n == node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3417 *next = n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3418 break; |
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 next = &n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3422 } |
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_queue_remove(&node->queue); |
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 weight = 0; |
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 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3429 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3430 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3431 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3432 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
|
3433 weight += child->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3434 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3435 |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3436 parent = node->parent; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3437 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3438 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3439 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3440 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3441 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3442 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
|
3443 child->parent = parent; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3444 child->weight = node->weight * child->weight / weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3445 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3446 if (child->weight == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3447 child->weight = 1; |
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 } |
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 if (parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3452 node->rank = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3453 node->rel_weight = 1.0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3454 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3455 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3456 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3457 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3458 node->rank = parent->rank; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3459 node->rel_weight = parent->rel_weight; |
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 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3462 } |
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 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3465 ngx_queue_add(children, &node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3466 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3467 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
|
3468 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3469 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3470 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3471 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3472 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3473 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3474 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
|
3475 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3476 u_char ch; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3477 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3478 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3479 |
6291
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3480 r->invalid_header = 0; |
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3481 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3482 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
|
3483 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3484 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
|
3485 ch = header->name.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3486 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3487 if ((ch >= 'a' && ch <= 'z') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3488 || (ch == '-') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3489 || (ch >= '0' && ch <= '9') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3490 || (ch == '_' && cscf->underscores_in_headers)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3491 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3492 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3493 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3494 |
7883
41f4bd4c51f1
Disabled control characters and space in header names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7877
diff
changeset
|
3495 if (ch <= 0x20 || ch == 0x7f || ch == ':' |
7216 | 3496 || (ch >= 'A' && ch <= 'Z')) |
3497 { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3498 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
|
3499 "client sent invalid header name: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3500 &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3501 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3502 return NGX_ERROR; |
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 r->invalid_header = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3506 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3507 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3508 for (i = 0; i != header->value.len; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3509 ch = header->value.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3510 |
7216 | 3511 if (ch == '\0' || ch == LF || ch == CR) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3512 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
|
3513 "client sent header \"%V\" with " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3514 "invalid value: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3515 &header->name, &header->value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3516 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3517 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3521 return NGX_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3524 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3525 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3526 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
|
3527 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3528 header->name.len--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3529 header->name.data++; |
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 switch (header->name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3532 case 4: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3533 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
|
3534 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3535 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3536 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
|
3537 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3538 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3539 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3540 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3541 case 6: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3542 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
|
3543 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3544 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3545 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
|
3546 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3547 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3548 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
|
3549 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3550 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3551 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
|
3552 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3553 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3554 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3555 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3556 case 9: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3557 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
|
3558 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3559 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3560 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
|
3561 } |
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 break; |
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 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
|
3567 "client sent unknown pseudo-header \":%V\"", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3568 &header->name); |
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 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3571 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3574 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3575 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
|
3576 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3577 if (r->unparsed_uri.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3578 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
|
3579 "client sent duplicate :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3580 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3581 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3582 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3583 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3584 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3585 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
|
3586 "client sent empty :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3587 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3588 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3589 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3590 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3591 r->uri_start = value->data; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3592 r->uri_end = value->data + value->len; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3593 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3594 if (ngx_http_parse_uri(r) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3595 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
|
3596 "client sent invalid :path header: \"%V\"", value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3597 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3598 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3599 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3600 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3601 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
|
3602 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3603 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3604 * in ngx_http_process_request_uri() |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3605 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3606 return NGX_ABORT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3607 } |
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_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3612 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3613 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3614 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
|
3615 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3616 size_t k, len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3617 ngx_uint_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3618 const u_char *p, *m; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3619 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3620 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3621 * This array takes less than 256 sequential bytes, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3622 * 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
|
3623 * it is prefetched for 4 load operations. |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3624 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3625 static const struct { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3626 u_char len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3627 const u_char method[11]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3628 uint32_t value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3629 } tests[] = { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3630 { 3, "GET", NGX_HTTP_GET }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3631 { 4, "POST", NGX_HTTP_POST }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3632 { 4, "HEAD", NGX_HTTP_HEAD }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3633 { 7, "OPTIONS", NGX_HTTP_OPTIONS }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3634 { 8, "PROPFIND", NGX_HTTP_PROPFIND }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3635 { 3, "PUT", NGX_HTTP_PUT }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3636 { 5, "MKCOL", NGX_HTTP_MKCOL }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3637 { 6, "DELETE", NGX_HTTP_DELETE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3638 { 4, "COPY", NGX_HTTP_COPY }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3639 { 4, "MOVE", NGX_HTTP_MOVE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3640 { 9, "PROPPATCH", NGX_HTTP_PROPPATCH }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3641 { 4, "LOCK", NGX_HTTP_LOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3642 { 6, "UNLOCK", NGX_HTTP_UNLOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3643 { 5, "PATCH", NGX_HTTP_PATCH }, |
7877
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3644 { 5, "TRACE", NGX_HTTP_TRACE }, |
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3645 { 7, "CONNECT", NGX_HTTP_CONNECT } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3646 }, *test; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3647 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3648 if (r->method_name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3649 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
|
3650 "client sent duplicate :method header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3651 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3652 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3653 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3654 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3655 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3656 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
|
3657 "client sent empty :method header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3658 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3659 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3660 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3661 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3662 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
|
3663 r->method_name.data = value->data; |
6246
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 len = r->method_name.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3666 n = sizeof(tests) / sizeof(tests[0]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3667 test = tests; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3668 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3669 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3670 if (len == test->len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3671 p = r->method_name.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3672 m = test->method; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3673 k = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3674 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3675 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3676 if (*p++ != *m++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3677 goto next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3678 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3679 } while (--k); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3680 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3681 r->method = test->value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3682 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3683 } |
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 next: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3686 test++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3687 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3688 } while (--n); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3689 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3690 p = r->method_name.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3691 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3692 do { |
6732
57148b755320
Allowed '-' in method names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6642
diff
changeset
|
3693 if ((*p < 'A' || *p > 'Z') && *p != '_' && *p != '-') { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3694 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
|
3695 "client sent invalid method: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3696 &r->method_name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3697 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3698 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3699 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3700 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3701 p++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3702 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3703 } while (--len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3704 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3705 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3706 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3709 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3710 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
|
3711 { |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3712 u_char c, ch; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3713 ngx_uint_t i; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3714 |
7295 | 3715 if (r->schema.len) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3716 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
|
3717 "client sent duplicate :scheme header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3718 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3719 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3720 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3721 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3722 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3723 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
|
3724 "client sent empty :scheme header"); |
6246
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 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3727 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3728 |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3729 for (i = 0; i < value->len; i++) { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3730 ch = value->data[i]; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3731 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3732 c = (u_char) (ch | 0x20); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3733 if (c >= 'a' && c <= 'z') { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3734 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3735 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3736 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3737 if (((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3738 && i > 0) |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3739 { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3740 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3741 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3742 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3743 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
|
3744 "client sent invalid :scheme header: \"%V\"", value); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3745 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3746 return NGX_DECLINED; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3747 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3748 |
7295 | 3749 r->schema = *value; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3750 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3751 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3752 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3753 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3754 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3755 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3756 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
|
3757 { |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3758 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
|
3759 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3760 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3761 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3762 static ngx_int_t |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3763 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
|
3764 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
|
3765 { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3766 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3767 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3768 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3769 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3770 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3771 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3772 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3773 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3774 h->key.len = header->name.len; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3775 h->key.data = header->name.data; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3776 h->lowcase_key = header->name.data; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3777 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3778 if (header->hh == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3779 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
|
3780 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3781 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
|
3782 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3783 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
|
3784 h->lowcase_key, h->key.len); |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3785 if (header->hh == NULL) { |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3786 return NGX_ERROR; |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3787 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3788 } |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3789 |
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3790 h->hash = header->hash; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3791 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3792 h->value.len = value->len; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3793 h->value.data = value->data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3794 |
7207
3d2b0b02bd3d
HTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov <ru@nginx.com>
parents:
7204
diff
changeset
|
3795 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
|
3796 /* header handler has already finalized request */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3797 return NGX_ABORT; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3800 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3801 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3804 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3805 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
|
3806 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3807 u_char *p; |
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 static const u_char ending[] = " HTTP/2.0"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3810 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3811 if (r->method_name.len == 0 |
7295 | 3812 || r->schema.len == 0 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3813 || r->unparsed_uri.len == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3814 { |
7106
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3815 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
|
3816 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
|
3817 "client sent no :method header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3818 |
7295 | 3819 } 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
|
3820 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
|
3821 "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
|
3822 |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3823 } else { |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3824 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
|
3825 "client sent no :path header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3826 } |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3827 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3828 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
|
3829 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3830 } |
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 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
|
3833 + r->unparsed_uri.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3834 + sizeof(ending) - 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3835 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3836 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
|
3837 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3838 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
|
3839 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3842 r->request_line.data = p; |
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 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
|
3845 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3846 *p++ = ' '; |
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 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
|
3849 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3850 ngx_memcpy(p, ending, sizeof(ending)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3851 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3852 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
|
3853 "http2 request line: \"%V\"", &r->request_line); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3854 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3855 return NGX_OK; |
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 |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3860 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
|
3861 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3862 ngx_str_t *val; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3863 ngx_array_t *cookies; |
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 cookies = r->stream->cookies; |
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 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3868 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
|
3869 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3870 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3871 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3872 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3873 r->stream->cookies = cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3874 } |
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 val = ngx_array_push(cookies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3877 if (val == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3878 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3879 } |
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 val->len = header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3882 val->data = header->value.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3883 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3884 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3885 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3888 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3889 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
|
3890 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3891 u_char *buf, *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3892 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3893 ngx_str_t *vals; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3894 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3895 ngx_array_t *cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3896 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3897 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3898 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3899 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3900 static ngx_str_t cookie = ngx_string("cookie"); |
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 cookies = r->stream->cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3903 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3904 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3905 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3906 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3907 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3908 vals = cookies->elts; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3909 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3910 i = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3911 len = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3912 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3913 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3914 len += vals[i].len + 2; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3915 } while (++i != cookies->nelts); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3916 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3917 len -= 2; |
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 buf = ngx_pnalloc(r->pool, len + 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3920 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3921 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
|
3922 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3925 p = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3926 end = buf + len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3927 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3928 for (i = 0; /* void */ ; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3929 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3930 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
|
3931 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3932 if (p == end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3933 *p = '\0'; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3934 break; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3937 *p++ = ';'; *p++ = ' '; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3938 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3939 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3940 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3941 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3942 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
|
3943 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3944 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3945 |
7209
3dfe9444324b
HTTP/2: precalculate hash for "Cookie".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7208
diff
changeset
|
3946 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
|
3947 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
|
3948 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3949 h->key.len = cookie.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3950 h->key.data = cookie.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3951 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3952 h->value.len = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3953 h->value.data = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3954 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3955 h->lowcase_key = cookie.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3956 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3957 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
|
3958 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3959 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
|
3960 h->lowcase_key, h->key.len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3961 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3962 if (hh == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3963 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
|
3964 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3967 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
|
3968 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3969 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3970 * in ngx_http_process_multi_header_lines() |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3971 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3972 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3973 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3974 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3975 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3976 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3977 |
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 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3980 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
|
3981 { |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3982 ngx_connection_t *fc; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3983 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
|
3984 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3985 fc = r->connection; |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3986 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3987 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
|
3988 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3989 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3990 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3991 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
|
3992 goto failed; |
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 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3996 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3997 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
|
3998 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3999 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4000 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4001 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
|
4002 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
|
4003 "client prematurely closed stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4004 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4005 r->stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4006 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4007 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
|
4008 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4009 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4010 |
6589
78533a74af11
HTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev <vbart@nginx.com>
parents:
6588
diff
changeset
|
4011 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
|
4012 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
|
4013 } |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4014 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
4015 h2c = r->stream->connection; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
4016 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
4017 h2c->payload_bytes += r->request_length; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
4018 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4019 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
|
4020 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
4021 failed: |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
4022 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
4023 ngx_http_run_posted_requests(fc); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4026 |
7201 | 4027 static void |
4028 ngx_http_v2_run_request_handler(ngx_event_t *ev) | |
4029 { | |
4030 ngx_connection_t *fc; | |
4031 ngx_http_request_t *r; | |
4032 | |
4033 fc = ev->data; | |
4034 r = fc->data; | |
4035 | |
4036 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, | |
4037 "http2 run request handler"); | |
4038 | |
4039 ngx_http_v2_run_request(r); | |
4040 } | |
4041 | |
4042 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4043 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
|
4044 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
|
4045 { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4046 off_t len; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4047 size_t size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4048 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4049 ngx_int_t rc; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4050 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
|
4051 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
|
4052 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
|
4053 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
|
4054 ngx_http_v2_connection_t *h2c; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4055 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4056 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
|
4057 rb = r->request_body; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4058 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4059 if (stream->skip_data) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4060 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
|
4061 rb->post_handler(r); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4062 return NGX_OK; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4063 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4064 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4065 rb->rest = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4066 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4067 /* set rb->filter_need_buffering */ |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4068 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4069 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
|
4070 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4071 if (rc != NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4072 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4073 return rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4074 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4075 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4076 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
|
4077 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
|
4078 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4079 len = r->headers_in.content_length_n; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4080 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4081 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
|
4082 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
|
4083 |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
4084 } else { |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
4085 len++; |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4086 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4087 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4088 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
|
4089 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4090 /* |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4091 * 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
|
4092 * 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
|
4093 */ |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4094 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4095 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
|
4096 len = h2scf->preread_size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4097 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4098 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4099 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
|
4100 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
|
4101 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4102 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4103 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4104 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
|
4105 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4106 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
|
4107 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4108 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4109 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4110 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4111 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4112 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4113 if (stream->in_closed) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4114 if (!rb->filter_need_buffering) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4115 r->request_body_no_buffering = 0; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4116 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4117 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4118 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4119 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
|
4120 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
|
4121 ngx_pfree(r->pool, buf->start); |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4122 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4123 } else { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4124 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
|
4125 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4126 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4127 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
|
4128 return rc; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4129 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4130 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4131 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
|
4132 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
|
4133 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4134 return NGX_AGAIN; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4135 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4136 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4137 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4138 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
|
4139 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
|
4140 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4141 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
|
4142 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4143 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
|
4144 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4145 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
|
4146 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4147 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4148 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4149 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
|
4150 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
|
4151 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4152 } else { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4153 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
|
4154 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
|
4155 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4156 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4157 if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4158 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
|
4159 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
|
4160 == NGX_ERROR) |
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
4161 { |
6519
9ac934dd5dd8
HTTP/2: skip data frames in case of internal errors.
Valentin Bartenev <vbart@nginx.com>
parents:
6518
diff
changeset
|
4162 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
|
4163 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
|
4164 } |
6520
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4165 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4166 h2c = stream->connection; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4167 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4168 if (!h2c->blocked) { |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4169 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
|
4170 stream->skip_data = 1; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4171 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
|
4172 } |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
4173 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4174 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4175 stream->recv_window += size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4176 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4177 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4178 if (!buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4179 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
|
4180 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4181 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4182 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
|
4183 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
|
4184 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4185 return NGX_AGAIN; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4186 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4187 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4188 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4189 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4190 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
|
4191 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
|
4192 { |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4193 size_t n; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4194 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4195 ngx_connection_t *fc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4196 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4197 ngx_http_core_loc_conf_t *clcf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4198 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4199 fc = r->connection; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4200 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4201 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4202 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
|
4203 "http2 process request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4204 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4205 if (size == 0 && !last && !flush) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4206 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
|
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 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4210 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4211 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
|
4212 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4213 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
|
4214 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4215 /* 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
|
4216 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4217 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
|
4218 "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
|
4219 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4220 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
|
4221 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4222 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4223 /* update chains */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4224 |
7921 | 4225 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
4226 "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
|
4227 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4228 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
|
4229 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4230 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
|
4231 return rc; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4232 } |
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 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
|
4235 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
|
4236 "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
|
4237 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
|
4238 } |
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 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
|
4241 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
|
4242 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4243 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4244 /* 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
|
4245 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4246 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
|
4247 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4248 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
|
4249 n = size; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4250 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4251 |
7916
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4252 if (n > 0) { |
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4253 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
|
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 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4256 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
|
4257 "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
|
4258 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4259 pos += n; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4260 size -= n; |
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 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
|
4263 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
|
4264 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4265 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4266 if (r->request_body_no_buffering && !flush) { |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4267 break; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4268 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4269 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4270 /* pass buffer to request body filter chain */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4271 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4272 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
|
4273 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4274 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
|
4275 return rc; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4276 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4277 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4278 if (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
|
4279 break; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4280 } |
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 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
|
4283 break; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4284 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4285 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4286 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4287 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
|
4288 "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
|
4289 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4290 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
|
4291 break; |
6496
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 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4294 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
|
4295 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
|
4296 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
|
4297 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4298 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
|
4299 if (!flush) { |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4300 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
|
4301 } |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4302 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4303 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
|
4304 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4305 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4306 return NGX_AGAIN; |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4307 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4308 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4309 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4310 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
|
4311 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
|
4312 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4313 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4314 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
|
4315 if (!flush) { |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4316 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
|
4317 } |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4318 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4319 return NGX_OK; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4320 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4321 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4322 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
|
4323 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
|
4324 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4325 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4326 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
|
4327 rb->post_handler(r); |
6496
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 return NGX_OK; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4330 } |
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 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4333 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4334 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
|
4335 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4336 ngx_buf_t *b, *buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4337 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4338 ngx_chain_t *cl; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4339 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4340 ngx_http_core_loc_conf_t *clcf; |
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 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4343 buf = rb->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4344 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4345 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
|
4346 cl = NULL; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4347 goto update; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4348 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4349 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4350 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
|
4351 if (cl == NULL) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4352 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4353 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4354 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4355 b = cl->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4356 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4357 ngx_memzero(b, sizeof(ngx_buf_t)); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4358 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4359 if (buf->pos != buf->last) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4360 r->request_length += buf->last - buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4361 rb->received += buf->last - buf->pos; |
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 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
|
4364 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
|
4365 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
|
4366 "client intended to send body data " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4367 "larger than declared"); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4368 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4369 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4370 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4371 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4372 } else { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4373 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
|
4374 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4375 if (clcf->client_max_body_size |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4376 && rb->received > clcf->client_max_body_size) |
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 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
|
4379 "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
|
4380 "%O bytes", rb->received); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4381 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4382 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4383 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4384 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4385 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4386 b->temporary = 1; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4387 b->pos = buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4388 b->last = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4389 b->start = b->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4390 b->end = b->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4391 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4392 buf->pos = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4393 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4394 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4395 if (!rb->rest) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4396 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
|
4397 && 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
|
4398 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4399 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
|
4400 "client prematurely closed stream: " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4401 "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
|
4402 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
|
4403 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4404 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4405 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4406 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4407 b->last_buf = 1; |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4408 rb->last_sent = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4409 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4410 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4411 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
|
4412 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
|
4413 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4414 update: |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4415 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4416 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
|
4417 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4418 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
|
4419 (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
|
4420 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4421 return rc; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4422 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4423 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4424 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4425 static void |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4426 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
|
4427 { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4428 size_t window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4429 ngx_buf_t *buf; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4430 ngx_int_t rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4431 ngx_connection_t *fc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4432 ngx_http_v2_stream_t *stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4433 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
|
4434 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4435 fc = r->connection; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4436 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4437 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
|
4438 "http2 read client request body handler"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4439 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4440 if (fc->read->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4441 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
|
4442 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4443 fc->timedout = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4444 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4445 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4446 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
|
4447 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4448 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4449 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4450 if (fc->error) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4451 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
|
4452 "client prematurely closed stream"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4453 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4454 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4455 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4456 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
|
4457 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4458 } |
7914
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 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
|
4461 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4462 if (rc != NGX_OK && rc != NGX_AGAIN) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4463 r->stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4464 ngx_http_finalize_request(r, rc); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4465 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4466 } |
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 if (rc == NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4469 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4470 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4471 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4472 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4473 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4474 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4475 |
7922
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4476 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
|
4477 return; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4478 } |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4479 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4480 stream = r->stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4481 h2c = stream->connection; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4482 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4483 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
|
4484 |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4485 buf->pos = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4486 buf->last = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4487 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4488 window = buf->end - buf->start; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4489 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4490 if (h2c->state.stream == stream) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4491 window -= h2c->state.length; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4492 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4493 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4494 if (window <= stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4495 if (window < stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4496 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
|
4497 "http2 negative window update"); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4498 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4499 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4500 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4501 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
|
4502 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4503 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4504 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4505 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4506 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4507 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4508 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
|
4509 window - stream->recv_window) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4510 == NGX_ERROR) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4511 { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4512 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4513 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
|
4514 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4515 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4516 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4517 stream->recv_window = window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4518 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4519 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
|
4520 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4521 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
|
4522 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4523 } |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4524 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4525 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4526 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4527 ngx_int_t |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4528 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
|
4529 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4530 size_t window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4531 ngx_buf_t *buf; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4532 ngx_int_t rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4533 ngx_connection_t *fc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4534 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
|
4535 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
|
4536 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4537 stream = r->stream; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4538 fc = r->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4539 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4540 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
|
4541 "http2 read unbuffered request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4542 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4543 if (fc->read->timedout) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4544 if (stream->recv_window) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4545 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4546 fc->timedout = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4547 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4548 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
|
4549 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4550 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4551 fc->read->timedout = 0; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4552 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4553 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4554 if (fc->error) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4555 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4556 return NGX_HTTP_BAD_REQUEST; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4557 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4558 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4559 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
|
4560 |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4561 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
|
4562 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4563 return rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4564 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4565 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4566 if (rc == NGX_OK) { |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4567 return NGX_OK; |
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 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4570 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4571 return NGX_AGAIN; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4572 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4573 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4574 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
|
4575 return NGX_AGAIN; |
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 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4578 buf = r->request_body->buf; |
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 buf->pos = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4581 buf->last = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4582 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4583 window = buf->end - buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4584 h2c = stream->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4585 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4586 if (h2c->state.stream == stream) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4587 window -= h2c->state.length; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4588 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4589 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4590 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
|
4591 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
|
4592 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
|
4593 "http2 negative window update"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4594 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4595 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
|
4596 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4597 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4598 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4599 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4600 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4601 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
|
4602 window - stream->recv_window) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4603 == NGX_ERROR) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4604 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4605 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4606 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
|
4607 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4608 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4609 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
|
4610 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4611 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
|
4612 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4613 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4614 stream->recv_window = window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4615 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4616 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4617 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4618 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4619 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4620 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4621 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
|
4622 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
|
4623 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4624 ngx_event_t *rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4625 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4626 |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4627 if (stream->rst_sent) { |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4628 return NGX_OK; |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4629 } |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4630 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4631 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
|
4632 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4633 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4634 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4635 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4636 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4637 stream->rst_sent = 1; |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4638 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4639 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4640 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4641 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4642 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4643 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4644 rev->handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4645 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4646 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4647 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4648 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4649 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4650 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4651 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
|
4652 { |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4653 ngx_pool_t *pool; |
7201 | 4654 ngx_uint_t push; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4655 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4656 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4657 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4658 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4659 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4660 h2c = stream->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4661 node = stream->node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4662 |
7201 | 4663 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
4664 "http2 close stream %ui, queued %ui, " | |
4665 "processing %ui, pushing %ui", | |
4666 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
|
4667 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4668 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4669 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4670 if (stream->queued) { |
7610
82c1339e2637
HTTP/2: fixed socket leak with queued frames (ticket #1689).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7571
diff
changeset
|
4671 fc->error = 1; |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4672 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
|
4673 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
|
4674 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4675 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4676 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4677 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
|
4678 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4679 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
|
4680 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
|
4681 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
|
4682 : 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
|
4683 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4684 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4685 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
|
4686 } |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4687 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4688 } 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
|
4689 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
|
4690 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4691 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4692 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
|
4693 } |
6246
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 |
6410
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4697 if (h2c->state.stream == stream) { |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4698 h2c->state.stream = NULL; |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4699 } |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4700 |
7201 | 4701 push = stream->node->id % 2 == 0; |
4702 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4703 node->stream = NULL; |
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 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4706 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4707 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4708 /* |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4709 * 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
|
4710 * 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
|
4711 * |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4712 * 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
|
4713 * 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
|
4714 */ |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4715 pool = stream->pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4716 |
7548
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4717 h2c->frames -= stream->frames; |
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4718 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4719 ngx_http_free_request(stream->request, rc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4720 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4721 if (pool != h2c->state.pool) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4722 ngx_destroy_pool(pool); |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4723 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4724 } else { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4725 /* 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
|
4726 h2c->state.keep_pool = 0; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4727 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4728 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4729 ev = fc->read; |
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 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4732 ngx_del_timer(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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4735 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4736 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4737 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4738 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4739 ev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4740 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4741 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4742 ngx_del_timer(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4743 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4744 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4745 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4746 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4747 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4748 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4749 fc->data = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4750 h2c->free_fake_connections = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4751 |
7201 | 4752 if (push) { |
4753 h2c->pushing--; | |
4754 | |
4755 } else { | |
4756 h2c->processing--; | |
4757 } | |
4758 | |
4759 if (h2c->processing || h2c->pushing || h2c->blocked) { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4760 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4761 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4762 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4763 ev = h2c->connection->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4764 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4765 ev->handler = ngx_http_v2_handle_connection_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4766 ngx_post_event(ev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4767 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4768 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4769 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4770 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4771 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
|
4772 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4773 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4774 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4775 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4776 fc = ev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4777 r = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4778 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4779 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
|
4780 "http2 close stream handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4781 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4782 if (ev->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4783 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
|
4784 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4785 fc->timedout = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4786 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4787 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
|
4788 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4789 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4790 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4791 ngx_http_v2_close_stream(r->stream, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4792 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4793 |
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 static void |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4796 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
|
4797 { |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4798 ngx_connection_t *fc; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4799 ngx_http_request_t *r; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4800 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4801 fc = ev->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4802 r = fc->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4803 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4804 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
|
4805 "http2 retry close stream handler"); |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4806 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4807 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
|
4808 } |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4809 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4810 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4811 static void |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4812 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
|
4813 { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4814 ngx_connection_t *c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4815 ngx_http_v2_connection_t *h2c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4816 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4817 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
|
4818 "http2 handle connection handler"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4819 |
6957
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4820 c = rev->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4821 h2c = c->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4822 |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4823 if (c->error) { |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4824 ngx_http_v2_finalize_connection(h2c, 0); |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4825 return; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4826 } |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4827 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4828 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4829 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4830 if (rev->ready) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4831 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4832 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4833 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4834 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4835 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
|
4836 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
|
4837 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4838 } |
6246
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 ngx_http_v2_handle_connection(c->data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4841 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4842 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4843 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4844 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4845 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
|
4846 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4847 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4848 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4849 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
|
4850 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4851 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4852 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4853 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4854 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4855 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
|
4856 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4857 if (rev->timedout || c->close) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4858 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
|
4859 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4860 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4861 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4862 #if (NGX_HAVE_KQUEUE) |
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 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4865 if (rev->pending_eof) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4866 c->log->handler = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4867 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
|
4868 "kevent() reported that client %V closed " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4869 "idle connection", &c->addr_text); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4870 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4871 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4872 c->ssl->no_send_shutdown = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4873 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4874 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4875 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4876 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4877 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4878 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4879 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4880 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4881 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4882 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
|
4883 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4884 |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4885 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
|
4886 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
|
4887 "http2 flood detected"); |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4888 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
|
4889 return; |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4890 } |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4891 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4892 c->destroyed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4893 ngx_reusable_connection(c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4894 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4895 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
|
4896 ngx_http_v2_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4897 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4898 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
|
4899 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4900 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
|
4901 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4904 c->write->handler = ngx_http_v2_write_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4905 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4906 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4907 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4908 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4911 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4912 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
|
4913 ngx_uint_t status) |
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 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4916 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4917 ngx_connection_t *c, *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4918 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4919 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4920 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4921 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4922 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4923 c = h2c->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4924 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4925 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4926 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4927 if (!c->error && !h2c->goaway) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4928 h2c->goaway = 1; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4929 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4930 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
|
4931 (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
|
4932 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4933 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4934 |
7201 | 4935 if (!h2c->processing && !h2c->pushing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4936 goto done; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4937 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4938 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4939 c->read->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4940 c->write->handler = ngx_http_empty_handler; |
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->last_out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4943 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4944 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
|
4945 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4946 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4947 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4948 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4949 for (i = 0; i < size; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4950 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4951 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
|
4952 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4953 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4954 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4955 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4956 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4957 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
4958 stream->waiting = 0; |
6246
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 r = stream->request; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4961 fc = r->connection; |
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 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4964 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4965 if (stream->queued) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4966 stream->queued = 0; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4967 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4968 ev = fc->write; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4969 ev->active = 0; |
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4970 ev->ready = 1; |
6246
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 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4973 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4974 } |
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 ev->eof = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4977 ev->handler(ev); |
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 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4980 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4981 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4982 |
7201 | 4983 if (h2c->processing || h2c->pushing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4984 c->error = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4985 return; |
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 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4988 done: |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4989 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4990 if (c->error) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4991 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4992 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4993 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4994 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
4995 ngx_http_v2_lingering_close(c); |
6246
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 |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5000 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
|
5001 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5002 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5003 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5004 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5005 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5006 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5007 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5008 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
|
5009 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5010 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5011 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5012 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5013 for (i = 0; i < size; i++) { |
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 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
|
5016 stream = node->stream; |
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 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5019 continue; |
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 if (delta > 0 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5023 && stream->send_window |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5024 > (ssize_t) (NGX_HTTP_V2_MAX_WINDOW - delta)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5025 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5026 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5027 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5028 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5029 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5030 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5031 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5032 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5033 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5034 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5035 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5036 stream->send_window += delta; |
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 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
|
5039 "http2:%ui adjusted window: %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5040 node->id, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5041 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5042 if (stream->send_window > 0 && stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5043 stream->exhausted = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5044 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5045 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5046 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5047 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5048 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5049 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
5050 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5051 wev->handler(wev); |
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 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5055 } |
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 return NGX_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5060 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5061 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5062 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
|
5063 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
|
5064 { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5065 ngx_queue_t *children, *q; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5066 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
|
5067 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5068 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
|
5069 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5070 if (parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5071 parent = NGX_HTTP_V2_ROOT; |
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 if (depend != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5074 exclusive = 0; |
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 = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5078 node->rel_weight = (1.0 / 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 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5081 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5082 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5083 if (node->parent != NULL) { |
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 for (next = parent->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5086 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
|
5087 next = next->parent) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5088 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5089 if (next != node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5090 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5091 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5092 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5093 ngx_queue_remove(&parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5094 ngx_queue_insert_after(&node->queue, &parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5095 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5096 parent->parent = node->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5097 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5098 if (node->parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5099 parent->rank = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5100 parent->rel_weight = (1.0 / 256) * parent->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5101 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5102 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5103 parent->rank = node->parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5104 parent->rel_weight = (node->parent->rel_weight / 256) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5105 * parent->weight; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5108 if (!exclusive) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5109 ngx_http_v2_node_children_update(parent); |
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 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5113 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5114 } |
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 node->rank = parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5117 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
|
5118 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5119 if (parent->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5120 ngx_queue_remove(&parent->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5121 ngx_queue_insert_tail(&h2c->closed, &parent->reuse); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5124 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5125 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5126 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5127 if (exclusive) { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5128 for (q = ngx_queue_head(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5129 q != ngx_queue_sentinel(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5130 q = ngx_queue_next(q)) |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5131 { |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5132 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
|
5133 child->parent = node; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5134 } |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
5135 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5136 ngx_queue_add(&node->children, children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5137 ngx_queue_init(children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5138 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5139 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5140 if (node->parent != NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5141 ngx_queue_remove(&node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5142 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5143 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5144 ngx_queue_insert_tail(children, &node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5145 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5146 node->parent = parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5147 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5148 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5149 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5150 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5151 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5152 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5153 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
|
5154 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5155 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5156 ngx_http_v2_node_t *child; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5157 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5158 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5159 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5160 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5161 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5162 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
|
5163 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5164 child->rank = node->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5165 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
|
5166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5167 ngx_http_v2_node_children_update(child); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5168 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5169 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5170 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5171 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5172 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5173 ngx_http_v2_pool_cleanup(void *data) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5174 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5175 ngx_http_v2_connection_t *h2c = data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5176 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5177 if (h2c->state.pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5178 ngx_destroy_pool(h2c->state.pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5179 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5180 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5181 if (h2c->pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5182 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5183 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5184 } |