Mercurial > hg > nginx
annotate src/http/v2/ngx_http_v2.c @ 9274:46ecad404a29 default tip
Mail: reset imap tag to empty after authentication attempt.
We need to reset the imap tag to empty after an authentication attempt
completes, otherwise if the next line parsed is incomplete with no tag
(e.g. empty line) then we use the "tag" from the previous buffer which
is now definitely wrong and has been partially overwritten with the most
recently read data (e.g. CRLF).
An example before this patch:
S: * OK IMAP4 ready
C: foobar login a b
S: foobar NO Incorrect username or password.
C:
S:
S: obar BAD invalid command
Then with this patch:
S: * OK IMAP4 ready
C: foobar login a b
S: foobar NO Incorrect username or password.
C:
S: * BAD invalid command
author | Rob Mueller <robm@fastmailteam.com> |
---|---|
date | Wed, 15 May 2024 10:06:00 +0300 |
parents | 388a801e9bb9 |
children |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
14 /* errors */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
15 #define NGX_HTTP_V2_NO_ERROR 0x0 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
16 #define NGX_HTTP_V2_PROTOCOL_ERROR 0x1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
17 #define NGX_HTTP_V2_INTERNAL_ERROR 0x2 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
18 #define NGX_HTTP_V2_FLOW_CTRL_ERROR 0x3 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
19 #define NGX_HTTP_V2_SETTINGS_TIMEOUT 0x4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
20 #define NGX_HTTP_V2_STREAM_CLOSED 0x5 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
21 #define NGX_HTTP_V2_SIZE_ERROR 0x6 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
22 #define NGX_HTTP_V2_REFUSED_STREAM 0x7 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
23 #define NGX_HTTP_V2_CANCEL 0x8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
24 #define NGX_HTTP_V2_COMP_ERROR 0x9 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
25 #define NGX_HTTP_V2_CONNECT_ERROR 0xa |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
26 #define NGX_HTTP_V2_ENHANCE_YOUR_CALM 0xb |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
27 #define NGX_HTTP_V2_INADEQUATE_SECURITY 0xc |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
28 #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
|
29 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
30 /* frame sizes */ |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
31 #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
|
32 #define NGX_HTTP_V2_RST_STREAM_SIZE 4 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
33 #define NGX_HTTP_V2_PRIORITY_SIZE 5 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
34 #define NGX_HTTP_V2_PING_SIZE 8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
35 #define NGX_HTTP_V2_GOAWAY_SIZE 8 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
36 #define NGX_HTTP_V2_WINDOW_UPDATE_SIZE 4 |
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 #define NGX_HTTP_V2_SETTINGS_PARAM_SIZE 6 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
39 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
40 /* settings fields */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
41 #define NGX_HTTP_V2_HEADER_TABLE_SIZE_SETTING 0x1 |
7201 | 42 #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
|
43 #define NGX_HTTP_V2_MAX_STREAMS_SETTING 0x3 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
44 #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
|
45 #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
|
46 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
47 #define NGX_HTTP_V2_FRAME_BUFFER_SIZE 24 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
48 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
49 #define NGX_HTTP_V2_ROOT (void *) -1 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
50 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
51 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
58 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
|
59 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
60 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
|
61 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
62 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
|
63 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
64 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
|
65 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
66 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
|
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_headers(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_header_block(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_field_len(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_field_huff(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_field_raw(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_field_skip(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_process_header(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_header_complete(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); |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
84 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
|
85 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
|
86 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
|
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_rst_stream(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_settings(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_settings_params(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); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
94 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
|
95 u_char *pos, u_char *end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
96 static u_char *ngx_http_v2_state_ping(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_goaway(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_window_update(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_continuation(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_complete(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_skip_padded(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_skip(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_save(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, 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
|
112 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
|
113 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
|
114 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
|
115 ngx_uint_t err); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
116 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
117 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
|
118 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
|
119 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
120 static ngx_http_v2_stream_t *ngx_http_v2_create_stream( |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
121 ngx_http_v2_connection_t *h2c); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
122 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
|
123 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
|
124 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
|
125 ngx_http_v2_connection_t *h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
126 #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
|
127 #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
|
128 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 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
|
133 ngx_uint_t sid, size_t window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 ngx_uint_t status); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
138 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
139 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
|
140 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
|
141 u_char flags, ngx_uint_t sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
142 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
|
143 ngx_http_v2_out_frame_t *frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
144 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
145 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
|
146 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
147 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
|
148 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
149 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
|
150 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
151 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
|
152 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
153 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
|
154 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
155 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
|
156 ngx_str_t *value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
157 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
|
158 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
|
159 ngx_http_v2_header_t *header); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
160 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
|
161 static void ngx_http_v2_run_request(ngx_http_request_t *r); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 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
|
166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 ngx_uint_t status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
175 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
176 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
|
177 ssize_t delta); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
182 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
|
183 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
184 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
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 #define NGX_HTTP_V2_FRAME_STATES \ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
199 (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
|
200 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
201 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
202 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
203 ngx_http_v2_init(ngx_event_t *rev) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
204 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
205 u_char *p, *end; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
206 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
207 ngx_pool_cleanup_t *cln; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
208 ngx_http_connection_t *hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
209 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
210 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
211 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
|
212 ngx_http_core_srv_conf_t *cscf; |
6246
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 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
215 hc = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
216 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
217 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
|
218 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
219 c->log->action = "processing HTTP/2 connection"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
220 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
221 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
|
222 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
223 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
224 h2mcf->recv_buffer = ngx_palloc(ngx_cycle->pool, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
225 h2mcf->recv_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
226 if (h2mcf->recv_buffer == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
227 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
228 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
229 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
230 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
231 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
232 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
|
233 if (h2c == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
234 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
235 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
236 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
237 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
238 h2c->connection = c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
239 h2c->http_connection = hc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
240 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
241 h2c->send_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
242 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
243 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
244 h2c->init_window = NGX_HTTP_V2_DEFAULT_WINDOW; |
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 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
|
247 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
248 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
|
249 |
7819
3674d5b7174e
HTTP/2: relaxed PRIORITY frames limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7805
diff
changeset
|
250 h2c->priority_limit = ngx_max(h2scf->concurrent_streams, 100); |
7201 | 251 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
252 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
|
253 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
254 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
255 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
256 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
257 |
6374
f598de1bfcd4
HTTP/2: fixed excessive memory allocation for pool cleanup.
Valentin Bartenev <vbart@nginx.com>
parents:
6312
diff
changeset
|
258 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
|
259 if (cln == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
260 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
261 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
262 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
263 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
264 cln->handler = ngx_http_v2_pool_cleanup; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
265 cln->data = h2c; |
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->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
|
268 * sizeof(ngx_http_v2_node_t *)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
269 if (h2c->streams_index == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
270 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
271 return; |
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 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
274 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
|
275 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
276 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
277 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
278 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
279 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
|
280 - NGX_HTTP_V2_DEFAULT_WINDOW) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
281 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
282 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
283 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
284 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
285 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
286 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
287 h2c->state.handler = ngx_http_v2_state_preface; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
288 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
289 ngx_queue_init(&h2c->waiting); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
290 ngx_queue_init(&h2c->dependencies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
291 ngx_queue_init(&h2c->closed); |
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 c->data = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
294 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
295 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
296 c->write->handler = ngx_http_v2_write_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
297 |
7783
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
298 if (!rev->timer_set) { |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
299 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
|
300 ngx_http_core_module); |
171682010da4
HTTP/2: client_header_timeout before first request (ticket #2142).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7774
diff
changeset
|
301 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
|
302 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
303 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
304 c->idle = 1; |
7769
0a5687a458de
HTTP/2: fixed reusing connections with active requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7768
diff
changeset
|
305 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
|
306 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
307 if (c->buffer) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
308 p = c->buffer->pos; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
309 end = c->buffer->last; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
310 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
311 do { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
312 p = h2c->state.handler(h2c, p, end); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
313 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
314 if (p == NULL) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
315 return; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
316 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
317 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
318 } while (p != end); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
319 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
320 h2c->total_bytes += p - c->buffer->pos; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
321 c->buffer->pos = p; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
322 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
323 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
324 ngx_http_v2_read_handler(rev); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
327 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
328 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
329 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
|
330 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
331 u_char *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
332 size_t available; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
333 ssize_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
334 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
335 ngx_http_v2_main_conf_t *h2mcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
336 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
337 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
338 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
339 h2c = c->data; |
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 if (rev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
342 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
|
343 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
|
344 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
345 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
346 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
347 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
|
348 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
349 h2c->blocked = 1; |
9165
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
350 h2c->new_streams = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
351 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
352 if (c->close) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
353 c->close = 0; |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
354 |
7571
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
355 if (c->error) { |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
356 ngx_http_v2_finalize_connection(h2c, 0); |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
357 return; |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
358 } |
ab5cac9d3f00
HTTP/2: fixed worker_shutdown_timeout.
Ruslan Ermilov <ru@nginx.com>
parents:
7570
diff
changeset
|
359 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
360 if (!h2c->processing) { |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
361 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
|
362 return; |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
363 } |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
364 |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
365 if (!h2c->goaway) { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
366 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
367 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
368 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
|
369 == NGX_ERROR) |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
370 { |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
371 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
|
372 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
373 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
374 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
375 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
|
376 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
|
377 return; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
378 } |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
379 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
380 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
381 h2c->blocked = 0; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
382 |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
383 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
384 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
385 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
386 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
|
387 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
388 |
9179
ea1f29c2010c
HTTP/2: fixed buffer management with HTTP/2 auto-detection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9165
diff
changeset
|
389 available = h2mcf->recv_buffer_size - NGX_HTTP_V2_STATE_BUFFER_SIZE; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
390 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
391 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
392 p = h2mcf->recv_buffer; |
9179
ea1f29c2010c
HTTP/2: fixed buffer management with HTTP/2 auto-detection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9165
diff
changeset
|
393 end = ngx_cpymem(p, h2c->state.buffer, h2c->state.buffer_used); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
394 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
395 n = c->recv(c, end, available); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
396 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
397 if (n == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
398 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
399 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
400 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
401 if (n == 0 && (h2c->state.incomplete || h2c->processing)) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
402 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
|
403 "client prematurely closed connection"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
404 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
405 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
406 if (n == 0 || n == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
407 c->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
408 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
409 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
410 } |
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 end += n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
413 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
414 h2c->state.buffer_used = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
415 h2c->state.incomplete = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
416 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
417 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
418 p = h2c->state.handler(h2c, p, end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
419 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
420 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
421 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
424 } while (p != end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
425 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
426 h2c->total_bytes += n; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
427 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 return; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
432 } |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
433 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
434 } while (rev->ready); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
435 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
436 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
|
437 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
|
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 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
|
442 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
443 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
444 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
445 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
446 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
447 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
448 ngx_http_v2_handle_connection(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
449 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
450 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
451 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
452 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
453 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
|
454 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
455 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
456 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
457 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
458 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
459 c = wev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
460 h2c = c->data; |
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 if (wev->timedout) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
463 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
|
464 "http2 write event timed out"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
465 c->error = 1; |
7695
d57f15922ca3
HTTP/2: fixed c->timedout flag on timed out connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7673
diff
changeset
|
466 c->timedout = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
467 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
468 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
469 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
470 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
471 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
|
472 |
6639
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
473 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
|
474 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
475 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
|
476 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
|
477 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
478 |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
479 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
|
480 return; |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
481 } |
82efcedb310b
HTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev <vbart@nginx.com>
parents:
6636
diff
changeset
|
482 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
483 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
484 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
485 rc = ngx_http_v2_send_output_queue(h2c); |
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 if (rc == NGX_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
488 ngx_http_v2_finalize_connection(h2c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
489 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
490 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
491 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
492 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
493 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
494 if (rc == NGX_AGAIN) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
495 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
496 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
497 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
498 ngx_http_v2_handle_connection(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
499 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
500 |
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 ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
503 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
|
504 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
505 int tcp_nodelay; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
506 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
507 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
508 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
509 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
|
510 ngx_http_core_loc_conf_t *clcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
511 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
512 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
|
513 wev = c->write; |
6246
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 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
|
516 goto error; |
d6cf51af8a3d
HTTP/2: fixed possible alert about left open socket on shutdown.
Ruslan Ermilov <ru@nginx.com>
parents:
7569
diff
changeset
|
517 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
518 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
519 if (!wev->ready) { |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
520 return NGX_AGAIN; |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
523 cl = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
524 out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
525 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
526 for (frame = h2c->last_out; frame; frame = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
527 frame->last->next = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
528 cl = frame->first; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
529 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
530 fn = frame->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
531 frame->next = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
532 out = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
533 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
534 ngx_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
|
535 "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
|
536 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
537 out->blocked, out->length); |
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 = c->send_chain(c, cl, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
542 if (cl == NGX_CHAIN_ERROR) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
543 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
544 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
545 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
546 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
|
547 ngx_http_core_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
548 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
549 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
|
550 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
551 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
552 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
553 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
554 if (ngx_tcp_push(c->fd) == -1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
555 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
|
556 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
557 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
559 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
560 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
|
561 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
562 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
563 tcp_nodelay = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
564 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
565 |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6989
diff
changeset
|
566 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
|
567 goto error; |
6246
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 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
571 fn = out->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
572 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
573 if (out->handler(h2c, out) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 out->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
577 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
578 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
|
579 "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
|
580 out, out->stream ? out->stream->node->id : 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 out->blocked, out->length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
583 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
584 frame = NULL; |
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 for ( /* void */ ; out; out = fn) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 fn = out->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
588 out->next = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
589 frame = out; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
590 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
591 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
592 h2c->last_out = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
593 |
6641
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
594 if (!wev->ready) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
595 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
|
596 return NGX_AGAIN; |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
597 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
598 |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
599 if (wev->timer_set) { |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
600 ngx_del_timer(wev); |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
601 } |
b5d1c17181ca
HTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev <vbart@nginx.com>
parents:
6640
diff
changeset
|
602 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
603 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
605 error: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
606 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
607 c->error = 1; |
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 if (!h2c->blocked) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
610 ngx_post_event(wev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
611 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
612 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
613 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
614 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
615 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
616 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
617 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
618 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
|
619 { |
7771
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
620 ngx_int_t rc; |
02be1baed382
HTTP/2: removed http2_recv_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7769
diff
changeset
|
621 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
|
622 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
623 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
624 if (h2c->last_out || h2c->processing) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
625 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
626 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
627 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
628 c = h2c->connection; |
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 if (c->error) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
631 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
632 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
635 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
|
636 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
|
637 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
638 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
|
639 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
640 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
|
641 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
642 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
|
643 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
|
644 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
645 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
646 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
647 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
|
648 return; |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
649 } |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
650 |
72282dd5884e
HTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev <vbart@nginx.com>
parents:
6641
diff
changeset
|
651 /* rc == NGX_OK */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
652 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
653 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
654 if (h2c->goaway) { |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
655 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
|
656 return; |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
657 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
658 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
659 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
|
660 ngx_http_core_module); |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
661 |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
662 if (!c->read->timer_set) { |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
663 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
|
664 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
665 |
7768
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
666 ngx_reusable_connection(c, 1); |
fc536dcdbbf7
HTTP/2: reuse of connections with incomplete frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7766
diff
changeset
|
667 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
668 if (h2c->state.incomplete) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
669 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
670 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
671 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
672 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
673 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
674 h2c->pool = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
675 h2c->free_frames = NULL; |
7377 | 676 h2c->frames = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
677 h2c->free_fake_connections = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
678 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
679 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
680 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
681 ngx_ssl_free_buffer(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
682 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
683 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
684 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
685 c->destroyed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
686 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
687 c->write->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
688 c->read->handler = ngx_http_v2_idle_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
689 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
690 if (c->write->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
691 ngx_del_timer(c->write); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
692 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
693 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
694 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
695 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
696 static void |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
697 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
|
698 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
699 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
|
700 ngx_http_v2_connection_t *h2c; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
701 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
702 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
703 h2c = c->data; |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
704 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
705 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
|
706 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
707 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
708 if (clcf->lingering_close == NGX_HTTP_LINGERING_OFF) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
709 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
710 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
711 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
712 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
713 if (h2c->lingering_time == 0) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
714 h2c->lingering_time = ngx_time() |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
715 + (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
|
716 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
717 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
718 #if (NGX_HTTP_SSL) |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
719 if (c->ssl) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
720 ngx_int_t rc; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
721 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
722 rc = ngx_ssl_shutdown(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
723 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
724 if (rc == NGX_ERROR) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
725 ngx_http_close_connection(c); |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
726 return; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
727 } |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
728 |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
729 if (rc == NGX_AGAIN) { |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
730 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
|
731 return; |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
732 } |
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 #endif |
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
735 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
736 rev = c->read; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
737 rev->handler = ngx_http_v2_lingering_close_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
738 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
739 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
|
740 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
741 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
742 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
743 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
744 wev = c->write; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
745 wev->handler = ngx_http_empty_handler; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
746 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
747 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
|
748 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
|
749 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
750 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
751 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
752 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
753 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
754 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
|
755 ngx_connection_error(c, ngx_socket_errno, |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
756 ngx_shutdown_socket_n " failed"); |
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 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
761 c->close = 0; |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
762 ngx_reusable_connection(c, 1); |
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
763 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
764 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
|
765 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
766 if (rev->ready) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
767 ngx_http_v2_lingering_close_handler(rev); |
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 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
772 static void |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
773 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
|
774 { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
775 ssize_t n; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
776 ngx_msec_t timer; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
777 ngx_connection_t *c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
778 ngx_http_core_loc_conf_t *clcf; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
779 ngx_http_v2_connection_t *h2c; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
780 u_char buffer[NGX_HTTP_LINGERING_BUFFER_SIZE]; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
781 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
782 c = rev->data; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
783 h2c = c->data; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
784 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
785 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
|
786 "http2 lingering close handler"); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
787 |
7766
3e83336cda5b
Reuse of connections in lingering close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7765
diff
changeset
|
788 if (rev->timedout || c->close) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
789 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
790 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
791 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
792 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
793 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
|
794 if ((ngx_msec_int_t) timer <= 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
795 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
796 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
797 } |
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 do { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
800 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
|
801 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
802 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
|
803 |
7765
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
804 if (n == NGX_AGAIN) { |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
805 break; |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
806 } |
519b55453c45
HTTP/2: lingering close changed to handle NGX_AGAIN.
Ruslan Ermilov <ru@nginx.com>
parents:
7751
diff
changeset
|
807 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
808 if (n == NGX_ERROR || n == 0) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
809 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
810 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
811 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
812 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
813 } while (rev->ready); |
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 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
|
816 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
817 return; |
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 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
820 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
|
821 ngx_http_core_module); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
822 timer *= 1000; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
823 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
824 if (timer > clcf->lingering_timeout) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
825 timer = clcf->lingering_timeout; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
826 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
827 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
828 ngx_add_timer(rev, timer); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
829 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
830 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
831 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
832 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
833 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
|
834 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
835 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
836 static const u_char preface[] = NGX_HTTP_V2_PREFACE_START; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
837 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
838 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
839 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
|
840 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
841 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
842 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
|
843 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
|
844 "invalid connection preface"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
845 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
846 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
|
847 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
848 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
849 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
|
850 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
851 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
854 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
|
855 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
856 { |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
857 static const u_char preface[] = NGX_HTTP_V2_PREFACE_END; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
858 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
859 if ((size_t) (end - pos) < sizeof(preface) - 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
860 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
|
861 ngx_http_v2_state_preface_end); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
862 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
863 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
864 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
|
865 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
|
866 "invalid connection preface"); |
6246
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 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
|
869 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
870 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
871 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
|
872 "http2 preface verified"); |
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 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
|
875 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
876 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
877 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
878 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
879 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
|
880 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
881 uint32_t head; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
882 ngx_uint_t type; |
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 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
|
885 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
|
886 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
887 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
888 head = ngx_http_v2_parse_uint32(pos); |
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 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
|
891 h2c->state.flags = pos[4]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
892 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
893 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
|
894 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
895 pos += NGX_HTTP_V2_FRAME_HEADER_SIZE; |
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 type = ngx_http_v2_parse_type(head); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
898 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
899 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
|
900 "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
|
901 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
|
902 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
903 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
|
904 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
|
905 "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
|
906 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
|
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 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
|
910 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
913 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 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
|
915 { |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
916 size_t size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
917 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
918 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
920 size = h2c->state.length; |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
921 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
922 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
|
923 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
924 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
925 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
|
926 "client sent padded DATA frame " |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
927 "with incorrect length: 0"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
928 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
929 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
|
930 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
931 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
932 if (end - pos == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
933 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
|
934 ngx_http_v2_state_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
935 } |
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 h2c->state.padding = *pos++; |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
938 |
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
939 if (h2c->state.padding >= size) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
940 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
|
941 "client sent padded DATA frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
942 "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
|
943 size, h2c->state.padding); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
944 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
945 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
|
946 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
947 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
948 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
949 h2c->state.length -= 1 + h2c->state.padding; |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
952 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
|
953 "http2 DATA frame"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
954 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
955 if (h2c->state.sid == 0) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
956 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
|
957 "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
|
958 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
959 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
|
960 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
961 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
962 if (size > h2c->recv_window) { |
6246
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 violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
965 "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
|
966 size, h2c->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
967 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
968 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
|
969 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
970 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
971 h2c->recv_window -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
972 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
973 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
|
974 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
975 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
|
976 - h2c->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
977 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
978 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
979 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
980 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
981 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
982 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
983 h2c->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
984 } |
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 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
|
987 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
988 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
989 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
|
990 "unknown http2 stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
991 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
992 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
|
993 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
994 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
995 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
996 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
997 if (size > stream->recv_window) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
998 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
|
999 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1000 "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
|
1001 node->id, size, stream->recv_window); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1002 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1003 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1004 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1005 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1006 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1007 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1008 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1009 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1010 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1011 return ngx_http_v2_state_skip_padded(h2c, pos, end); |
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 |
6954
052305810ca4
HTTP/2: fix flow control with padded DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
6834
diff
changeset
|
1014 stream->recv_window -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1016 if (stream->no_flow_control |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1017 && 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
|
1018 { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1019 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
|
1020 NGX_HTTP_V2_MAX_WINDOW |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1021 - stream->recv_window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1022 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1023 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1024 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1025 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1026 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1028 stream->recv_window = NGX_HTTP_V2_MAX_WINDOW; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1031 if (stream->in_closed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1032 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
|
1033 "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
|
1034 node->id); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1035 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1037 NGX_HTTP_V2_STREAM_CLOSED) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1038 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1039 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1040 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1041 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1042 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1043 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1044 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
|
1045 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1046 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 h2c->state.stream = stream; |
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_read_data(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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1052 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1053 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1054 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
|
1055 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1056 { |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
1057 size_t size; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1058 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1059 ngx_int_t rc; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1060 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
|
1061 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
|
1062 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
|
1063 ngx_http_v2_srv_conf_t *h2scf; |
6246
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 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1066 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1067 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1068 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
|
1069 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1071 if (stream->skip_data) { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1072 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
|
1073 "skipping http2 DATA frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1074 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 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
|
1076 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1077 |
7561
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1078 r = stream->request; |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1079 fc = r->connection; |
7561
9f1f9d6e056a
HTTP/2: discard remaining request body after redirect.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7549
diff
changeset
|
1080 |
7710
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1081 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
|
1082 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
|
1083 "skipping http2 DATA frame"); |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1084 |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1085 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
|
1086 } |
097f578a4a8f
HTTP/2: fixed segfault on DATA frames after 400 errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7703
diff
changeset
|
1087 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1088 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1089 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1090 if (size >= h2c->state.length) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1091 size = h2c->state.length; |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
1092 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
|
1093 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1094 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1095 h2c->payload_bytes += size; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
1096 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1097 if (r->request_body) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1098 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
|
1099 stream->in_closed, 0); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1100 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
1101 if (rc != NGX_OK && rc != NGX_AGAIN) { |
9259
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
1102 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1103 stream->skip_data = 1; |
9263
388a801e9bb9
Request body: discarded body now treated as no body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9260
diff
changeset
|
1104 r->discard_body = 1; |
9259
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
1105 r->request_body->bufs = NULL; |
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
1106 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1107 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
|
1108 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1109 |
7711
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1110 ngx_http_run_posted_requests(fc); |
526dddf637bb
HTTP/2: run posted requests after reading body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7710
diff
changeset
|
1111 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1112 } else if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1113 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1114 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1115 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1116 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
|
1117 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1118 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
|
1119 if (buf == NULL) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1120 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
|
1121 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
|
1122 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1123 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1124 stream->preread = buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1125 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1126 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1127 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
|
1128 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
|
1129 "http2 preread buffer overflow"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1130 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
|
1131 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
|
1132 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1133 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1134 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
|
1135 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1136 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1137 pos += size; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
1138 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1139 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1140 if (h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1141 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
|
1142 ngx_http_v2_state_read_data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1143 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1144 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1145 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1146 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
|
1147 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1148 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1149 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
|
1150 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1151 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1152 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1153 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1154 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
|
1155 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1156 { |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1157 size_t size; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1158 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
|
1159 weight; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1160 ngx_uint_t status; |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1167 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
|
1168 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
|
1169 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1170 size = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1171 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1172 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1173 size++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1174 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1175 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1176 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1177 size += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1178 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1179 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1180 if (h2c->state.length < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1181 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
|
1182 "client sent HEADERS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1183 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1184 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1185 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
|
1186 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1187 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1188 if (h2c->state.length == size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1189 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
|
1190 "client sent HEADERS frame with empty header block"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1191 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1192 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
|
1193 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1194 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1195 if (h2c->goaway) { |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1196 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
|
1197 "skipping http2 HEADERS frame"); |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1198 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
|
1199 } |
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
1200 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1201 if ((size_t) (end - pos) < size) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1202 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
|
1203 ngx_http_v2_state_headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1204 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1205 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1206 h2c->state.length -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1207 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1208 if (padded) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1209 h2c->state.padding = *pos++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1210 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1211 if (h2c->state.padding > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1212 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
|
1213 "client sent padded HEADERS frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1214 "with incorrect length: %uz, padding: %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1215 h2c->state.length, h2c->state.padding); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1216 |
6955
d38161da62cd
HTTP/2: emit PROTOCOL_ERROR on padding errors.
Piotr Sikora <piotrsikora@google.com>
parents:
6954
diff
changeset
|
1217 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
|
1218 NGX_HTTP_V2_PROTOCOL_ERROR); |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1221 h2c->state.length -= h2c->state.padding; |
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 depend = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1225 excl = 0; |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1226 weight = NGX_HTTP_V2_DEFAULT_WEIGHT; |
6246
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 if (priority) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1229 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1230 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1231 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1232 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1233 weight = pos[4] + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1234 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1235 pos += sizeof(uint32_t) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1236 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1237 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1238 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
|
1239 "http2 HEADERS frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
1240 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1241 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1242 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1243 if (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
|
1244 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
|
1245 "client sent HEADERS frame with incorrect identifier " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1246 "%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
|
1247 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1248 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
|
1249 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1250 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1251 if (depend == h2c->state.sid) { |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1252 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
|
1253 "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
|
1254 "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
|
1255 |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1256 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
|
1257 } |
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
1258 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1259 h2c->last_sid = h2c->state.sid; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1260 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1261 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
|
1262 if (h2c->state.pool == NULL) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1263 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
|
1264 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1265 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1266 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
|
1267 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
|
1268 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1269 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
|
1270 * 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
|
1271 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1272 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
|
1273 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1274 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1275 if (h2c->processing >= h2scf->concurrent_streams) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1276 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
|
1277 "concurrent streams exceeded %ui", h2c->processing); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1278 |
6513
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1279 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
|
1280 goto rst_stream; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1281 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1282 |
9165
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1283 if (h2c->new_streams++ >= 2 * h2scf->concurrent_streams) { |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1284 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1285 "client sent too many streams at once"); |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1286 |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1287 status = NGX_HTTP_V2_REFUSED_STREAM; |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1288 goto rst_stream; |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1289 } |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1290 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1291 if (!h2c->settings_ack |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
1292 && !(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
|
1293 && 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
|
1294 { |
6516
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1295 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
|
1296 "client sent stream with data " |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1297 "before settings were acknowledged"); |
ab16126a06a0
HTTP/2: write logs when refusing streams with data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6515
diff
changeset
|
1298 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1299 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
|
1300 goto rst_stream; |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1301 } |
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
1302 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1303 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
|
1304 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1305 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1306 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
|
1307 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1308 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1309 if (node->parent) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1310 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1311 h2c->closed_nodes--; |
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 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
1314 stream = ngx_http_v2_create_stream(h2c); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1315 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1316 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
|
1317 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1318 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1319 h2c->state.stream = stream; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1320 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1321 stream->pool = h2c->state.pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1322 h2c->state.keep_pool = 1; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1323 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1324 stream->request->request_length = h2c->state.length; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1325 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1326 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
|
1327 stream->node = node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1328 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1329 node->stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1330 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1331 if (priority || node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1332 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1333 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
|
1334 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1335 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1336 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
|
1337 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
1338 |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1339 if (clcf->keepalive_timeout == 0 |
7820
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1340 || h2c->connection->requests >= clcf->keepalive_requests |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1341 || ngx_current_msec - h2c->connection->start_time |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7819
diff
changeset
|
1342 > clcf->keepalive_time) |
7805
ade8160120c1
HTTP/2: improved handling of "keepalive_timeout 0".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7783
diff
changeset
|
1343 { |
6783
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1344 h2c->goaway = 1; |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1345 |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1346 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
|
1347 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
|
1348 NGX_HTTP_V2_INTERNAL_ERROR); |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1349 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1350 } |
9027991e2f37
HTTP/2: limited maximum number of requests in connection.
Valentin Bartenev <vbart@nginx.com>
parents:
6778
diff
changeset
|
1351 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1352 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
|
1353 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1354 rst_stream: |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1355 |
9165
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1356 if (h2c->refused_streams++ > ngx_max(h2scf->concurrent_streams, 100)) { |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1357 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1358 "client sent too many refused streams"); |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1359 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_NO_ERROR); |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1360 } |
cdda286c0f1b
HTTP/2: per-iteration stream handling limit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9121
diff
changeset
|
1361 |
6513
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1362 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
|
1363 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
|
1364 } |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1365 |
80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev <vbart@nginx.com>
parents:
6497
diff
changeset
|
1366 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
|
1367 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1368 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1369 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1370 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1371 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
|
1372 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1373 { |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1374 u_char ch; |
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1375 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
|
1376 ngx_uint_t indexed, size_update, prefix; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1377 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1378 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1379 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
|
1380 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1381 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1382 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1383 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
|
1384 && 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
|
1385 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1386 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
|
1387 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
|
1388 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1389 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1390 size_update = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1391 indexed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1392 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1393 ch = *pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1394 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1395 if (ch >= (1 << 7)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1396 /* indexed header field */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1397 indexed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1398 prefix = ngx_http_v2_prefix(7); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1399 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1400 } else if (ch >= (1 << 6)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1401 /* literal header field with incremental indexing */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1402 h2c->state.index = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1403 prefix = ngx_http_v2_prefix(6); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1404 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1405 } else if (ch >= (1 << 5)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1406 /* dynamic table size update */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1407 size_update = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1408 prefix = ngx_http_v2_prefix(5); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1409 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1410 } else if (ch >= (1 << 4)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1411 /* literal header field never indexed */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1412 prefix = ngx_http_v2_prefix(4); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1413 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1414 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1415 /* 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
|
1416 prefix = ngx_http_v2_prefix(4); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1417 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1418 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1419 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
|
1420 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1421 if (value < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1422 if (value == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1423 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
|
1424 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1425 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1426 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1427 if (value == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1428 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
|
1429 "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
|
1430 size_update ? "size update" : "header index"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1431 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1432 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
|
1433 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1434 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1435 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
|
1436 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1437 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1438 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
|
1439 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1440 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1441 if (indexed) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1442 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
|
1443 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
|
1444 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1445 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1446 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
|
1447 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1448 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1449 if (size_update) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1450 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
|
1451 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
|
1452 } |
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 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
|
1455 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1456 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1457 if (value == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1458 h2c->state.parse_name = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1459 |
6285
1f26bf65b1bc
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
6284
diff
changeset
|
1460 } 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
|
1461 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
|
1462 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1463 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1464 h2c->state.parse_value = 1; |
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 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
|
1467 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1468 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1469 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1470 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1471 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
|
1472 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1473 { |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1474 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
|
1475 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
|
1476 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
|
1477 ngx_http_core_srv_conf_t *cscf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1478 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1479 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
|
1480 && 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
|
1481 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1482 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
|
1483 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
|
1484 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1485 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1486 if (h2c->state.length < 1) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1487 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
|
1488 "client sent header block with incorrect length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1489 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1490 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
|
1491 } |
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 if (end - pos < 1) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1494 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
|
1495 ngx_http_v2_state_field_len); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1496 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1497 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1498 huff = *pos >> 7; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1499 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
|
1500 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1501 if (len < 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1502 if (len == NGX_AGAIN) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1503 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
|
1504 ngx_http_v2_state_field_len); |
6246
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 if (len == NGX_DECLINED) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1508 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1509 "client sent header field with too long length value"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1510 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1511 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1512 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1513 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1514 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
|
1515 "client sent header block with incorrect length"); |
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 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
|
1518 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1519 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1520 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
|
1521 "http2 %s string, len:%i", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1522 huff ? "encoded" : "raw", len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1523 |
7774
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1524 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
|
1525 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
|
1526 |
827202ca1269
HTTP/2: removed http2_max_field_size and http2_max_header_size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7773
diff
changeset
|
1527 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
|
1528 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
|
1529 "client sent too large header field"); |
6246
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 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
|
1532 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1533 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1534 h2c->state.field_rest = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1535 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1536 if (h2c->state.stream == NULL && !h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1537 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
|
1538 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1539 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1540 alloc = (huff ? len * 8 / 5 : len) + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1541 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1542 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
|
1543 if (h2c->state.field_start == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1544 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
|
1545 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1546 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1547 h2c->state.field_end = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1548 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1549 if (huff) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1550 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
|
1551 } |
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 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
|
1554 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1555 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1556 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1557 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1558 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
|
1559 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1560 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1561 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1562 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1563 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1564 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1565 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1566 size = h2c->state.field_rest; |
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 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1569 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
|
1570 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1571 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1572 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1573 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1574 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1575 |
7977
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1576 if (ngx_http_huff_decode(&h2c->state.field_state, pos, size, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1577 &h2c->state.field_end, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1578 h2c->state.field_rest == 0, |
336084ff943b
Moved Huffman coding out of HTTP/2.
Ruslan Ermilov <ru@nginx.com>
parents:
7924
diff
changeset
|
1579 h2c->connection->log) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1580 != NGX_OK) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1581 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1582 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
|
1583 "client sent invalid encoded header field"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1584 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1585 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
|
1586 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1587 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1588 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1589 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1590 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
|
1591 *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
|
1592 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
|
1593 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1594 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1595 if (h2c->state.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1596 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
|
1597 ngx_http_v2_state_field_huff); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1598 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1599 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1600 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
|
1601 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
|
1602 "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
|
1603 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1604 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
|
1605 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1606 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1607 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
|
1608 ngx_http_v2_state_field_huff); |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1611 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1612 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1613 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
|
1614 u_char *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 size_t size; |
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 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1619 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1620 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1621 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1622 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1623 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1624 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
|
1625 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1626 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1627 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1628 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1629 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1630 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1631 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
|
1632 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1633 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1634 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1635 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
|
1636 *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
|
1637 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
|
1638 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1639 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1640 if (h2c->state.length) { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
1641 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
|
1642 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1643 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1644 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1645 if (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
|
1646 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
|
1647 "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
|
1648 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1649 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
|
1650 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1651 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1652 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
|
1653 ngx_http_v2_state_field_raw); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1654 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1655 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1656 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1657 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1658 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
|
1659 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1660 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1661 size_t size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1662 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1663 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1664 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1665 if (size > h2c->state.field_rest) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1666 size = h2c->state.field_rest; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1667 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1668 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1669 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
|
1670 size = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1671 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1672 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1673 h2c->state.length -= size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1674 h2c->state.field_rest -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1675 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1676 pos += size; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1677 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1678 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
|
1679 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
|
1680 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1681 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1682 if (h2c->state.length) { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1683 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
|
1684 ngx_http_v2_state_field_skip); |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1685 } |
f5380c244cd7
HTTP/2: fixed HPACK header field parsing.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1686 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1687 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
|
1688 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
|
1689 "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
|
1690 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1691 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
|
1692 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1693 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1694 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
|
1695 ngx_http_v2_state_field_skip); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1696 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1697 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1698 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1699 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1700 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
|
1701 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1702 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1703 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1704 ngx_int_t rc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1705 ngx_table_elt_t *h; |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1706 ngx_connection_t *fc; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1707 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1708 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1709 ngx_http_v2_header_t *header; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1710 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1711 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1712 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1713 static ngx_str_t cookie = ngx_string("cookie"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1714 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1715 header = &h2c->state.header; |
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 if (h2c->state.parse_name) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1718 h2c->state.parse_name = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1719 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1720 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
|
1721 header->name.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1722 |
7547
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1723 if (header->name.len == 0) { |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1724 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
|
1725 "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
|
1726 |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1727 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
|
1728 NGX_HTTP_V2_PROTOCOL_ERROR); |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1729 } |
4f4b83f00cf1
HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7378
diff
changeset
|
1730 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1731 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
|
1732 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1733 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1734 if (h2c->state.parse_value) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1735 h2c->state.parse_value = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1736 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1737 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
|
1738 header->value.data = h2c->state.field_start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1739 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1740 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1741 len = header->name.len + header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1742 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1743 if (len > h2c->state.header_limit) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1744 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
|
1745 "client sent too large header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1746 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1747 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
|
1748 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1749 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1750 h2c->state.header_limit -= len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1751 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1752 if (h2c->state.index) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1753 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
|
1754 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1755 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1756 } |
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 h2c->state.index = 0; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1761 if (h2c->state.stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1762 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
|
1763 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1764 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1765 r = h2c->state.stream->request; |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1766 fc = r->connection; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1767 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1768 /* TODO Optimization: validate headers while parsing. */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1769 if (ngx_http_v2_validate_header(r, header) != NGX_OK) { |
8148
9db24374123b
HTTP/2: finalize request as bad if header validation fails.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8147
diff
changeset
|
1770 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
|
1771 goto error; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1774 if (header->name.data[0] == ':') { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1775 rc = ngx_http_v2_pseudo_header(r, 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 (rc == NGX_OK) { |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1778 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
|
1779 "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
|
1780 &header->name, &header->value); |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1781 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1782 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
|
1783 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1784 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1785 if (rc == NGX_ABORT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1786 goto error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1787 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1788 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1789 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
|
1790 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
|
1791 goto error; |
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 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
|
1795 } |
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 if (r->invalid_header) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1798 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
|
1799 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1800 if (cscf->ignore_invalid_headers) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1801 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
|
1802 "client sent invalid header: \"%V\"", &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1803 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1804 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
|
1805 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1808 if (header->name.len == cookie.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1809 && 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
|
1810 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1811 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
|
1812 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1813 NGX_HTTP_V2_INTERNAL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1814 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1815 |
7016
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1816 } else { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1817 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
|
1818 if (h == NULL) { |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1819 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
|
1820 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
|
1821 } |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1822 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1823 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
|
1824 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
|
1825 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1826 /* |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1827 * TODO Optimization: precalculate hash |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1828 * 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
|
1829 */ |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1830 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
|
1831 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1832 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
|
1833 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
|
1834 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1835 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
|
1836 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1837 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
|
1838 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1839 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
|
1840 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
|
1841 |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1842 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
|
1843 goto error; |
ab6ef3037840
HTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora <piotrsikora@google.com>
parents:
7007
diff
changeset
|
1844 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1845 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1846 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1847 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
|
1848 "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
|
1849 &header->name, &header->value); |
6246
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 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
|
1852 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1853 error: |
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 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1856 |
8147
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1857 ngx_http_run_posted_requests(fc); |
72627f1cf09e
HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7977
diff
changeset
|
1858 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1859 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
|
1860 } |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1864 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
|
1865 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1866 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1867 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1868 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1869 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
|
1870 if (end - pos > 0) { |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1871 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
|
1872 return pos; |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1873 } |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1874 |
72b792bb3885
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7618
diff
changeset
|
1875 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
|
1876 ngx_http_v2_state_header_block); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1877 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1878 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1879 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
|
1880 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
|
1881 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
|
1882 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1883 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1884 stream = h2c->state.stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1885 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1886 if (stream) { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1887 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
|
1888 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1889 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1890 if (!h2c->state.keep_pool) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1891 ngx_destroy_pool(h2c->state.pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1892 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1893 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1894 h2c->state.pool = NULL; |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
1895 h2c->state.keep_pool = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1896 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1897 if (h2c->state.padding) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1898 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
|
1899 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1900 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1901 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
|
1902 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1903 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1904 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1905 static u_char * |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1906 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
|
1907 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
|
1908 { |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1909 u_char *p; |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1910 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
|
1911 uint32_t head; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1912 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1913 len = h2c->state.length; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1914 |
6376
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1915 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
|
1916 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
|
1917 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1918 h2c->state.padding -= skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1919 |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1920 p = pos; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1921 pos += skip; |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1922 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
|
1923 } |
0e0e2e522fa2
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev <vbart@nginx.com>
parents:
6375
diff
changeset
|
1924 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1925 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
|
1926 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
|
1927 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1928 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1929 p = pos + len; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1930 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1931 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
|
1932 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1933 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
|
1934 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
|
1935 "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
|
1936 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1937 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
|
1938 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1939 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1940 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
|
1941 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1942 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
|
1943 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
|
1944 "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
|
1945 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1946 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
|
1947 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1948 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1949 p = pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1950 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
|
1951 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1952 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
|
1953 |
6375
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1954 len = ngx_http_v2_parse_length(head); |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1955 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1956 h2c->state.length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1957 |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1958 if (h2c->state.stream) { |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1959 h2c->state.stream->request->request_length += len; |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1960 } |
e30c72b0dfda
HTTP/2: fixed request length accounting.
Valentin Bartenev <vbart@nginx.com>
parents:
6374
diff
changeset
|
1961 |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1962 h2c->state.handler = handler; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1963 return pos; |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1964 } |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1965 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1966 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
1967 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1968 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
|
1969 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1970 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1971 ngx_uint_t depend, dependency, excl, weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1972 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1973 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1974 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
|
1975 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
|
1976 "client sent PRIORITY frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1977 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1978 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1979 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
|
1980 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1981 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
1982 if (--h2c->priority_limit == 0) { |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
1983 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
|
1984 "client sent too many PRIORITY frames"); |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
1985 |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
1986 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
|
1987 } |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
1988 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1989 if (end - pos < NGX_HTTP_V2_PRIORITY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1990 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
|
1991 ngx_http_v2_state_priority); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1992 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1993 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1994 dependency = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1995 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1996 depend = dependency & 0x7fffffff; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1997 excl = dependency >> 31; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1998 weight = pos[4] + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1999 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2000 pos += NGX_HTTP_V2_PRIORITY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2001 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2002 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
|
2003 "http2 PRIORITY frame sid:%ui " |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2004 "depends on %ui excl:%ui weight:%ui", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2005 h2c->state.sid, depend, excl, weight); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2006 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2007 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2008 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
|
2009 "client sent PRIORITY frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2010 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2011 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
|
2012 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2013 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2014 if (depend == h2c->state.sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2015 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
|
2016 "client sent PRIORITY frame for stream %ui " |
6284
66ee1c5cb6aa
HTTP/2: fixed spelling.
Valentin Bartenev <vbart@nginx.com>
parents:
6280
diff
changeset
|
2017 "with incorrect dependency", h2c->state.sid); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2018 |
7564
29b2dc731503
HTTP/2: close connection on frames with self-dependency.
Ruslan Ermilov <ru@nginx.com>
parents:
7561
diff
changeset
|
2019 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
|
2020 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2021 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2022 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
|
2023 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2024 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2025 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
|
2026 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2027 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2028 node->weight = weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2029 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2030 if (node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2031 if (node->parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2032 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2033 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2034 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2035 ngx_queue_remove(&node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2036 } |
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 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2039 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2040 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2041 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
|
2042 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2043 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
|
2044 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2045 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2046 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2047 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2048 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
|
2049 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2050 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2051 ngx_uint_t status; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2052 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2053 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2054 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2055 ngx_http_v2_stream_t *stream; |
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 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
|
2058 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
|
2059 "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
|
2060 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2061 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2062 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
|
2063 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2064 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2065 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
|
2066 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
|
2067 ngx_http_v2_state_rst_stream); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2068 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2069 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2070 status = ngx_http_v2_parse_uint32(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2071 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2072 pos += NGX_HTTP_V2_RST_STREAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2073 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2074 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
|
2075 "http2 RST_STREAM frame, sid:%ui status:%ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2076 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2077 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2078 if (h2c->state.sid == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2079 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2080 "client sent RST_STREAM frame with incorrect identifier"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2081 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2082 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
|
2083 } |
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 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
|
2086 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2087 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2088 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
|
2089 "unknown http2 stream"); |
6246
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 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
|
2092 } |
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 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2095 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2096 stream->in_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2097 stream->out_closed = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2098 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2099 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2100 fc->error = 1; |
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 switch (status) { |
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 case NGX_HTTP_V2_CANCEL: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2105 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
|
2106 "client canceled stream %ui", h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2107 break; |
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 case NGX_HTTP_V2_INTERNAL_ERROR: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2110 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
|
2111 "client terminated stream %ui due to internal error", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2112 h2c->state.sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2113 break; |
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 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2116 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
|
2117 "client terminated stream %ui with status %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2118 h2c->state.sid, status); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2119 break; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2122 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2123 ev->handler(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2124 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2125 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
|
2126 } |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2130 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
|
2131 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2132 { |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2133 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
|
2134 "http2 SETTINGS frame"); |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2135 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2136 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2137 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
|
2138 "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
|
2139 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2140 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
|
2141 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2142 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2143 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
|
2144 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2145 if (h2c->state.length != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2146 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
|
2147 "client sent SETTINGS frame with the ACK flag " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2148 "and nonzero length"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2149 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2150 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
|
2151 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2152 |
6514
0aa07850922f
HTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev <vbart@nginx.com>
parents:
6513
diff
changeset
|
2153 h2c->settings_ack = 1; |
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 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
|
2159 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
|
2160 "client sent SETTINGS frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2161 h2c->state.length); |
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 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
|
2164 } |
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 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
|
2167 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2168 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2169 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2170 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2171 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
|
2172 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2173 { |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2174 ssize_t window_delta; |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2175 ngx_uint_t id, value; |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2176 ngx_http_v2_out_frame_t *frame; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2177 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2178 window_delta = 0; |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2179 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2180 while (h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2181 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
|
2182 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
|
2183 ngx_http_v2_state_settings_params); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2184 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2185 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2186 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
|
2187 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2188 id = ngx_http_v2_parse_uint16(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2189 value = ngx_http_v2_parse_uint32(&pos[2]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2190 |
7191
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2191 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
|
2192 "http2 setting %ui:%ui", id, value); |
61d276dcd493
HTTP/2: more style, comments, and debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7190
diff
changeset
|
2193 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2194 switch (id) { |
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 case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: |
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 if (value > NGX_HTTP_V2_MAX_WINDOW) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2199 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
|
2200 "client sent SETTINGS frame with incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2201 "INITIAL_WINDOW_SIZE value %ui", value); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2202 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2203 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2204 NGX_HTTP_V2_FLOW_CTRL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2205 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2206 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2207 window_delta = value - h2c->init_window; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2208 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2209 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2210 case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING: |
6958
28dc369899ea
HTTP/2: style and typos.
Piotr Sikora <piotrsikora@google.com>
parents:
6957
diff
changeset
|
2211 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2212 if (value > NGX_HTTP_V2_MAX_FRAME_SIZE |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2213 || value < NGX_HTTP_V2_DEFAULT_FRAME_SIZE) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2214 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2215 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 incorrect " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2217 "MAX_FRAME_SIZE value %ui", value); |
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, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2220 NGX_HTTP_V2_PROTOCOL_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2221 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2222 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2223 h2c->frame_size = value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2224 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2225 |
7201 | 2226 case NGX_HTTP_V2_ENABLE_PUSH_SETTING: |
2227 | |
2228 if (value > 1) { | |
2229 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
2230 "client sent SETTINGS frame with incorrect " | |
2231 "ENABLE_PUSH value %ui", value); | |
2232 | |
2233 return ngx_http_v2_connection_error(h2c, | |
2234 NGX_HTTP_V2_PROTOCOL_ERROR); | |
2235 } | |
2236 | |
2237 break; | |
2238 | |
7335
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2239 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
|
2240 |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2241 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
|
2242 break; |
fbb683496705
HTTP/2: workaround for clients which fail on table size updates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7296
diff
changeset
|
2243 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2244 default: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2245 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2246 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2247 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2248 pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2249 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2250 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2251 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
|
2252 NGX_HTTP_V2_SETTINGS_FRAME, |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2253 NGX_HTTP_V2_ACK_FLAG, 0); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2254 if (frame == NULL) { |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2255 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
|
2256 } |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2257 |
7025
7206c3630310
HTTP/2: don't send SETTINGS ACK before already queued DATA frames.
Piotr Sikora <piotrsikora@google.com>
parents:
7024
diff
changeset
|
2258 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
|
2259 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2260 if (window_delta) { |
7190
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2261 h2c->init_window += window_delta; |
e11a0679d349
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov <ru@nginx.com>
parents:
7118
diff
changeset
|
2262 |
7022
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2263 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
|
2264 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
|
2265 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
|
2266 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2267 } |
645ed7112a01
HTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora <piotrsikora@google.com>
parents:
7016
diff
changeset
|
2268 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2269 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
|
2270 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2271 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2274 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
|
2275 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2276 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2277 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
|
2278 "client sent PUSH_PROMISE frame"); |
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 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
|
2281 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2282 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2283 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2284 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2285 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
|
2286 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2287 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2288 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2289 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2290 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
|
2291 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
|
2292 "client sent PING frame with incorrect length %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2293 h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2294 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2295 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
|
2296 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2297 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2298 if (end - pos < NGX_HTTP_V2_PING_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2299 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
|
2300 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2301 |
7241
190591ab0d76
HTTP/2: improved frame info debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
7229
diff
changeset
|
2302 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
|
2303 "http2 PING frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2304 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2305 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2306 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
|
2307 "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
|
2308 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2309 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
|
2310 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2311 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2312 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
|
2313 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
|
2314 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2315 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2316 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
|
2317 NGX_HTTP_V2_PING_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2318 NGX_HTTP_V2_ACK_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2319 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2320 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
|
2321 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2322 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2323 buf = frame->first->buf; |
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 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
|
2326 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2327 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2328 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2329 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
|
2330 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2331 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2332 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2333 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2334 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
|
2335 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2336 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2337 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2338 ngx_uint_t last_sid, error; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2339 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2340 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2341 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
|
2342 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
|
2343 "client sent GOAWAY frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2344 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2345 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2346 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
|
2347 } |
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 if (end - pos < NGX_HTTP_V2_GOAWAY_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2350 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
|
2351 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2352 |
7703
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2353 if (h2c->state.sid) { |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2354 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
|
2355 "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
|
2356 |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2357 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
|
2358 } |
da5e3f5b1673
HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7695
diff
changeset
|
2359 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2360 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2361 h2c->state.length -= NGX_HTTP_V2_GOAWAY_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2362 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2363 last_sid = ngx_http_v2_parse_sid(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2364 error = ngx_http_v2_parse_uint32(&pos[4]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2365 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2366 pos += NGX_HTTP_V2_GOAWAY_SIZE; |
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 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
|
2369 "http2 GOAWAY frame: last sid %ui, error %ui", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2370 last_sid, error); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2371 #endif |
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_state_skip(h2c, pos, end); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2377 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2378 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
|
2379 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2380 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2381 size_t window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2382 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2383 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2384 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2385 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2386 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2387 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
|
2388 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
|
2389 "client sent WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2390 "with incorrect length %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2391 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2392 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
|
2393 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2394 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2395 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
|
2396 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
|
2397 ngx_http_v2_state_window_update); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2398 } |
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 window = ngx_http_v2_parse_window(pos); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2401 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2402 pos += NGX_HTTP_V2_WINDOW_UPDATE_SIZE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2403 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2404 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
|
2405 "http2 WINDOW_UPDATE frame sid:%ui window:%uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2406 h2c->state.sid, window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2407 |
6988
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2408 if (window == 0) { |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2409 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
|
2410 "client sent WINDOW_UPDATE frame " |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2411 "with incorrect window increment 0"); |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2412 |
fd6dcc6f8a49
HTTP/2: close connection on zero WINDOW_UPDATE.
Ruslan Ermilov <ru@nginx.com>
parents:
7564
diff
changeset
|
2413 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
|
2414 } |
cc823122d50d
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev <vbart@nginx.com>
parents:
6958
diff
changeset
|
2415 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2416 if (h2c->state.sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2417 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
|
2418 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2419 if (node == NULL || node->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2420 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
|
2421 "unknown http2 stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2422 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2423 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
|
2424 } |
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 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2427 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2428 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
|
2429 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2430 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
|
2431 "client violated flow control for stream %ui: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2432 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2433 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2434 "not allowed for window %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2435 h2c->state.sid, window, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2436 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2437 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2438 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2439 == NGX_ERROR) |
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 return ngx_http_v2_connection_error(h2c, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2442 NGX_HTTP_V2_INTERNAL_ERROR); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2445 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
|
2446 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2447 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2448 stream->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2449 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2450 if (stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2451 stream->exhausted = 0; |
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 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2454 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2455 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2456 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2457 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2458 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2459 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2460 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2461 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2462 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2463 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
|
2464 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2465 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2466 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
|
2467 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
|
2468 "client violated connection flow control: " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2469 "received WINDOW_UPDATE frame " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2470 "with window increment %uz " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2471 "not allowed for window %uz", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2472 window, h2c->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2473 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2474 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
|
2475 } |
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 h2c->send_window += window; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2478 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2479 while (!ngx_queue_empty(&h2c->waiting)) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2480 q = ngx_queue_head(&h2c->waiting); |
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_queue_remove(q); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2483 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2484 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
|
2485 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
2486 stream->waiting = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2487 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2488 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2489 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2490 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2491 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2492 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2493 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2494 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2495 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2496 if (h2c->send_window == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2497 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2498 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2499 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2500 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2501 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2502 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
|
2503 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2504 |
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 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2507 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
|
2508 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2509 { |
6249
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2510 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
|
2511 "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
|
2512 |
081a073e5164
HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
Valentin Bartenev <vbart@nginx.com>
parents:
6248
diff
changeset
|
2513 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
|
2514 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2515 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2516 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2517 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2518 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
|
2519 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2520 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2521 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
|
2522 "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
|
2523 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2524 if (pos > end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2525 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
|
2526 "receive buffer overrun"); |
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 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
|
2529 } |
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 h2c->state.stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2532 h2c->state.handler = ngx_http_v2_state_head; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2533 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2534 return pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2535 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2536 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2537 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2538 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2539 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
|
2540 u_char *end) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2541 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2542 h2c->state.length += h2c->state.padding; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2543 h2c->state.padding = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2544 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2545 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
|
2546 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2547 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2548 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2549 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2550 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
|
2551 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2552 size_t size; |
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 size = end - pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2555 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2556 if (size < h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2557 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
|
2558 "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
|
2559 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2560 h2c->state.length -= size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2561 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
|
2562 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2563 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2564 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
|
2565 "http2 frame skip %uz", h2c->state.length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2566 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2567 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
|
2568 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2569 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2570 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2571 static u_char * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2572 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
|
2573 ngx_http_v2_handler_pt handler) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2574 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2575 size_t size; |
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 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
|
2578 "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
|
2579 pos, end, handler); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2580 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2581 size = end - pos; |
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 if (size > NGX_HTTP_V2_STATE_BUFFER_SIZE) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2584 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
|
2585 "state buffer overflow: %uz bytes required", size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2586 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2587 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
|
2588 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2589 |
9179
ea1f29c2010c
HTTP/2: fixed buffer management with HTTP/2 auto-detection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9165
diff
changeset
|
2590 ngx_memcpy(h2c->state.buffer, pos, size); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2591 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2592 h2c->state.buffer_used = size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2593 h2c->state.handler = handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2594 h2c->state.incomplete = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2595 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2596 return end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2597 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2598 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2599 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2600 static u_char * |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2601 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
|
2602 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
|
2603 { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2604 ngx_event_t *rev; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2605 ngx_http_request_t *r; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2606 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
|
2607 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2608 if (h2c->state.stream) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2609 r = h2c->state.stream->request; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2610 rev = r->connection->read; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2611 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2612 if (!rev->timer_set) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2613 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
|
2614 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
|
2615 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2616 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2617 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2618 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
|
2619 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2620 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2621 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
2622 static u_char * |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2623 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
|
2624 ngx_uint_t err) |
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 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
|
2627 "http2 state connection error"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2628 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2629 ngx_http_v2_finalize_connection(h2c, err); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2630 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2631 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2632 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2633 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2634 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2635 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2636 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
|
2637 ngx_uint_t prefix) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2638 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2639 u_char *start, *p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2640 ngx_uint_t value, octet, shift; |
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 start = *pos; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2643 p = start; |
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 value = *p++ & prefix; |
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 if (value != prefix) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2648 if (h2c->state.length == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2649 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2650 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2651 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2652 h2c->state.length--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2653 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2654 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2655 return value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2656 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2657 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2658 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
|
2659 end = start + NGX_HTTP_V2_INT_OCTETS; |
6246
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2662 for (shift = 0; p != end; shift += 7) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2663 octet = *p++; |
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 value += (octet & 0x7f) << shift; |
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 if (octet < 128) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2668 if ((size_t) (p - start) > h2c->state.length) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2669 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2670 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2671 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2672 h2c->state.length -= p - start; |
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 *pos = p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2675 return value; |
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 |
6268
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2679 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
|
2680 return NGX_ERROR; |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2681 } |
ee16fb0db905
HTTP/2: improved error handling while parsing integers.
Valentin Bartenev <vbart@nginx.com>
parents:
6267
diff
changeset
|
2682 |
6267
adaac65899c8
HTTP/2: improved HPACK integer parsing code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6260
diff
changeset
|
2683 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
|
2684 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2685 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2686 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2687 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2688 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2689 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2690 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2691 static ngx_int_t |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2692 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
|
2693 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2694 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2695 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2696 ngx_chain_t *cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2697 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2698 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2699 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2700 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
|
2701 "http2 send SETTINGS frame"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2702 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2703 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
|
2704 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2705 return NGX_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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2708 cl = ngx_alloc_chain_link(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2709 if (cl == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2710 return NGX_ERROR; |
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 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2713 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
|
2714 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2715 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
|
2716 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2717 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2718 } |
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 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2721 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2722 cl->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2723 cl->next = NULL; |
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 frame->first = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2726 frame->last = cl; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2727 frame->handler = ngx_http_v2_settings_frame_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2728 frame->stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2729 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2730 frame->length = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2731 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2732 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2733 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2734 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
|
2735 NGX_HTTP_V2_SETTINGS_FRAME); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2736 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2737 *buf->last++ = NGX_HTTP_V2_NO_FLAG; |
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 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
|
2740 |
7024
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2741 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
|
2742 ngx_http_v2_module); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2743 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2744 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
|
2745 NGX_HTTP_V2_MAX_STREAMS_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2746 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
|
2747 h2scf->concurrent_streams); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2748 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2749 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
|
2750 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
|
2751 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
|
2752 |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2753 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
|
2754 NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING); |
79de0d2aa432
HTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora <piotrsikora@google.com>
parents:
7023
diff
changeset
|
2755 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
|
2756 NGX_HTTP_V2_MAX_FRAME_SIZE); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2757 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2758 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2759 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2760 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2761 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2762 |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2765 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
|
2766 ngx_http_v2_out_frame_t *frame) |
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 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2769 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2770 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2771 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2772 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2773 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2774 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2775 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2776 ngx_free_chain(h2c->pool, frame->first); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2777 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2778 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2779 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2780 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2781 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2782 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2783 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
|
2784 size_t window) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2785 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2786 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2787 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2788 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2789 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
|
2790 "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
|
2791 sid, window); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2792 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2793 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
|
2794 NGX_HTTP_V2_WINDOW_UPDATE_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2795 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2796 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2797 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2798 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2799 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2800 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2801 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2802 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
|
2803 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2804 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2805 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2806 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2807 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2808 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2809 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2810 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2811 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
|
2812 ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2813 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2814 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2815 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2816 |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2817 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
|
2818 "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
|
2819 sid, status); |
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2820 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2821 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
|
2822 NGX_HTTP_V2_RST_STREAM_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2823 NGX_HTTP_V2_NO_FLAG, sid); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2824 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2825 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2826 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2827 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2828 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2829 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2830 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
|
2831 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2832 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2833 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2834 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2835 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2836 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2837 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2838 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2839 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
|
2840 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2841 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2842 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2843 |
6790
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
2844 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
|
2845 "http2 send GOAWAY frame: last sid %ui, error %ui", |
727c6412673a
HTTP/2: slightly improved debugging.
Ruslan Ermilov <ru@nginx.com>
parents:
6783
diff
changeset
|
2846 h2c->last_sid, status); |
6448
4d1d3c2530e0
HTTP/2: improved debugging of sending control frames.
Valentin Bartenev <vbart@nginx.com>
parents:
6412
diff
changeset
|
2847 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2848 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
|
2849 NGX_HTTP_V2_GOAWAY_FRAME, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2850 NGX_HTTP_V2_NO_FLAG, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2851 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2852 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2853 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2854 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2855 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2856 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2857 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
|
2858 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
|
2859 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2860 ngx_http_v2_queue_blocked_frame(h2c, frame); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2861 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2862 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2863 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2864 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2865 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2866 static ngx_http_v2_out_frame_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2867 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
|
2868 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
|
2869 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2870 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2871 ngx_pool_t *pool; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2872 ngx_http_v2_out_frame_t *frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2873 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2874 frame = h2c->free_frames; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2875 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2876 if (frame) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2877 h2c->free_frames = frame->next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2878 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2879 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2880 buf->pos = buf->start; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2881 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2882 frame->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2883 |
7377 | 2884 } else if (h2c->frames < 10000) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2885 pool = h2c->pool ? h2c->pool : h2c->connection->pool; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2886 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2887 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
|
2888 if (frame == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2889 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2890 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2891 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2892 frame->first = ngx_alloc_chain_link(pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2893 if (frame->first == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2894 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2895 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2896 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2897 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
|
2898 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2899 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2900 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2901 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2902 buf->last_buf = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2903 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2904 frame->first->buf = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2905 frame->last = frame->first; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2906 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2907 frame->handler = ngx_http_v2_frame_handler; |
7377 | 2908 |
2909 h2c->frames++; | |
2910 | |
2911 } else { | |
2912 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | |
2913 "http2 flood detected"); | |
2914 | |
2915 h2c->connection->error = 1; | |
2916 return NULL; | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2917 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2918 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2919 #if (NGX_DEBUG) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2920 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
|
2921 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2922 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
|
2923 "requested control frame is too large: %uz", length); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2924 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2925 } |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
2926 #endif |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2927 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2928 frame->length = length; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2929 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2930 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
|
2931 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2932 *buf->last++ = flags; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2933 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2934 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
|
2935 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2936 return frame; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2939 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2940 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2941 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
|
2942 ngx_http_v2_out_frame_t *frame) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2943 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2944 ngx_buf_t *buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2945 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2946 buf = frame->first->buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2947 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2948 if (buf->pos != buf->last) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2949 return NGX_AGAIN; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2950 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2951 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2952 frame->next = h2c->free_frames; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2953 h2c->free_frames = frame; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2954 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
2955 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
|
2956 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2957 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2958 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2961 static ngx_http_v2_stream_t * |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
2962 ngx_http_v2_create_stream(ngx_http_v2_connection_t *h2c) |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2963 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2964 ngx_log_t *log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2965 ngx_event_t *rev, *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2966 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2967 ngx_http_log_ctx_t *ctx; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2968 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2969 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
|
2970 ngx_http_v2_srv_conf_t *h2scf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2971 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2972 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2973 fc = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2974 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2975 if (fc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2976 h2c->free_fake_connections = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2977 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2978 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2979 wev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2980 log = fc->log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2981 ctx = log->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2982 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2983 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2984 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
|
2985 if (fc == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2986 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2987 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2988 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2989 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
|
2990 if (rev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2991 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2994 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
|
2995 if (wev == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2996 return NULL; |
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 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
|
3000 if (log == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3001 return NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3004 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
|
3005 if (ctx == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3006 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3007 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3008 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3009 ctx->connection = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3010 ctx->request = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3011 ctx->current_request = NULL; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3014 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
|
3015 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3016 log->data = ctx; |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3017 log->action = "reading client request headers"; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3018 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3019 ngx_memzero(rev, sizeof(ngx_event_t)); |
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 rev->data = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3022 rev->ready = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3023 rev->handler = ngx_http_v2_close_stream_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3024 rev->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3025 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3026 ngx_memcpy(wev, rev, sizeof(ngx_event_t)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3027 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3028 wev->write = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3029 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3030 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
|
3031 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3032 fc->data = h2c->http_connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3033 fc->read = rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3034 fc->write = wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3035 fc->sent = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3036 fc->log = log; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3037 fc->buffered = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3038 fc->sndlowat = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3039 fc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
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 r = ngx_http_create_request(fc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3042 if (r == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3043 return NULL; |
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 |
6256
9dfc4ba140f9
HTTP/2: fixed $server_protocol value (ticket #800).
Valentin Bartenev <vbart@nginx.com>
parents:
6249
diff
changeset
|
3046 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
|
3047 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3048 r->http_version = NGX_HTTP_VERSION_20; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3049 r->valid_location = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3050 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3051 fc->data = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3052 h2c->connection->requests++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3053 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3054 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
|
3055 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3056 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
|
3057 cscf->client_header_buffer_size); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3058 if (r->header_in == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3059 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
|
3060 return NULL; |
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 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
|
3064 sizeof(ngx_table_elt_t)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3065 != NGX_OK) |
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_free_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3068 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3069 } |
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 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
|
3072 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3073 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
|
3074 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3075 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
|
3076 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3077 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3078 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3079 r->stream = stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3080 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3081 stream->request = r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3082 stream->connection = h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3083 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3084 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
|
3085 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3086 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
|
3087 stream->recv_window = h2scf->preread_size; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3088 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3089 h2c->processing++; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3090 |
7549
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3091 h2c->priority_limit += h2scf->concurrent_streams; |
45415228990b
HTTP/2: limited number of PRIORITY frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7548
diff
changeset
|
3092 |
7773
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3093 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
|
3094 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
|
3095 } |
b64f553b1291
HTTP/2: keepalive_timeout now armed once between requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7772
diff
changeset
|
3096 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3097 return stream; |
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_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3102 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
|
3103 ngx_uint_t alloc) |
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_uint_t index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3106 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3107 ngx_http_v2_srv_conf_t *h2scf; |
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 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
|
3110 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3111 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3112 index = ngx_http_v2_index(h2scf, sid); |
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 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
|
3115 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3116 if (node->id == sid) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3117 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3118 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3119 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3120 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3121 if (!alloc) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3122 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3123 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3124 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3125 if (h2c->closed_nodes < 32) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3126 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
|
3127 if (node == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3128 return NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3129 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3130 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3131 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3132 node = ngx_http_v2_get_closed_node(h2c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3133 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3134 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3135 node->id = sid; |
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 ngx_queue_init(&node->children); |
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 node->index = h2c->streams_index[index]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3140 h2c->streams_index[index] = node; |
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 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3143 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3144 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3145 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3146 static ngx_http_v2_node_t * |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3147 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
|
3148 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3149 ngx_uint_t weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3150 ngx_queue_t *q, *children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3151 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
|
3152 ngx_http_v2_srv_conf_t *h2scf; |
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 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
|
3155 ngx_http_v2_module); |
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 h2c->closed_nodes--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3158 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3159 q = ngx_queue_head(&h2c->closed); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3160 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3161 ngx_queue_remove(q); |
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 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
|
3164 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3165 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
|
3166 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3167 for ( ;; ) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3168 n = *next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3169 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3170 if (n == node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3171 *next = n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3172 break; |
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 next = &n->index; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3176 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3177 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3178 ngx_queue_remove(&node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3179 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3180 weight = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3181 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3182 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3183 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3184 q = ngx_queue_next(q)) |
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 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
|
3187 weight += child->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3188 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3189 |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3190 parent = node->parent; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
3191 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3192 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3193 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3194 q = ngx_queue_next(q)) |
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 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
|
3197 child->parent = parent; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3198 child->weight = node->weight * child->weight / weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3199 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3200 if (child->weight == 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3201 child->weight = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3202 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3203 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3204 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3205 if (parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3206 node->rank = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3207 node->rel_weight = 1.0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3208 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3209 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3210 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3211 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3212 node->rank = parent->rank; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3213 node->rel_weight = parent->rel_weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3214 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3215 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3216 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3217 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3218 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3219 ngx_queue_add(children, &node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3220 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3221 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
|
3222 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3223 return node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3224 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3225 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3226 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3227 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3228 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
|
3229 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3230 u_char ch; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3231 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3232 ngx_http_core_srv_conf_t *cscf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3233 |
6291
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3234 r->invalid_header = 0; |
932a465537ef
HTTP/2: fixed invalid headers handling (ticket #831).
Valentin Bartenev <vbart@nginx.com>
parents:
6288
diff
changeset
|
3235 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3236 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
|
3237 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3238 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
|
3239 ch = header->name.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3240 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3241 if ((ch >= 'a' && ch <= 'z') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3242 || (ch == '-') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3243 || (ch >= '0' && ch <= '9') |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3244 || (ch == '_' && cscf->underscores_in_headers)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3245 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3246 continue; |
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 |
7883
41f4bd4c51f1
Disabled control characters and space in header names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7877
diff
changeset
|
3249 if (ch <= 0x20 || ch == 0x7f || ch == ':' |
7216 | 3250 || (ch >= 'A' && ch <= 'Z')) |
3251 { | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3252 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
|
3253 "client sent invalid header name: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3254 &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3255 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3256 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3257 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3258 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3259 r->invalid_header = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3260 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3261 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3262 for (i = 0; i != header->value.len; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3263 ch = header->value.data[i]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3264 |
7216 | 3265 if (ch == '\0' || ch == LF || ch == CR) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3266 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
|
3267 "client sent header \"%V\" with " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3268 "invalid value: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3269 &header->name, &header->value); |
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 return NGX_ERROR; |
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 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3274 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3275 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3276 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3277 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3278 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3279 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3280 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
|
3281 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3282 header->name.len--; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3283 header->name.data++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3284 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3285 switch (header->name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3286 case 4: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3287 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
|
3288 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3289 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3290 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
|
3291 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3292 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3293 break; |
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 case 6: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3296 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
|
3297 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3298 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3299 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
|
3300 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3301 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3302 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
|
3303 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3304 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3305 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
|
3306 } |
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 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3309 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3310 case 9: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3311 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
|
3312 == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3313 { |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3314 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
|
3315 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3316 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3317 break; |
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 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
|
3321 "client sent unknown pseudo-header \":%V\"", |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3322 &header->name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3323 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3324 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3325 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3326 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3327 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3328 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3329 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
|
3330 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3331 if (r->unparsed_uri.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3332 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
|
3333 "client sent duplicate :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3334 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3335 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3336 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3337 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3338 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3339 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
|
3340 "client sent empty :path header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3341 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3342 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3343 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3344 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3345 r->uri_start = value->data; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3346 r->uri_end = value->data + value->len; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3347 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3348 if (ngx_http_parse_uri(r) != NGX_OK) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3349 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
|
3350 "client sent invalid :path header: \"%V\"", value); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3351 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3352 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3353 } |
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 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
|
3356 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3357 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3358 * in ngx_http_process_request_uri() |
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 return NGX_ABORT; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3363 return NGX_OK; |
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 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3368 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
|
3369 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3370 size_t k, len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3371 ngx_uint_t n; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3372 const u_char *p, *m; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3373 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3374 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3375 * This array takes less than 256 sequential bytes, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3376 * 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
|
3377 * it is prefetched for 4 load operations. |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3378 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3379 static const struct { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3380 u_char len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3381 const u_char method[11]; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3382 uint32_t value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3383 } tests[] = { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3384 { 3, "GET", NGX_HTTP_GET }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3385 { 4, "POST", NGX_HTTP_POST }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3386 { 4, "HEAD", NGX_HTTP_HEAD }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3387 { 7, "OPTIONS", NGX_HTTP_OPTIONS }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3388 { 8, "PROPFIND", NGX_HTTP_PROPFIND }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3389 { 3, "PUT", NGX_HTTP_PUT }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3390 { 5, "MKCOL", NGX_HTTP_MKCOL }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3391 { 6, "DELETE", NGX_HTTP_DELETE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3392 { 4, "COPY", NGX_HTTP_COPY }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3393 { 4, "MOVE", NGX_HTTP_MOVE }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3394 { 9, "PROPPATCH", NGX_HTTP_PROPPATCH }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3395 { 4, "LOCK", NGX_HTTP_LOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3396 { 6, "UNLOCK", NGX_HTTP_UNLOCK }, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3397 { 5, "PATCH", NGX_HTTP_PATCH }, |
7877
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3398 { 5, "TRACE", NGX_HTTP_TRACE }, |
63c66b7cc07c
Added CONNECT method rejection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7820
diff
changeset
|
3399 { 7, "CONNECT", NGX_HTTP_CONNECT } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3400 }, *test; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3401 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3402 if (r->method_name.len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3403 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
|
3404 "client sent duplicate :method header"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3405 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3406 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3407 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3408 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3409 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3410 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
|
3411 "client sent empty :method header"); |
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 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3414 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3415 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3416 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
|
3417 r->method_name.data = value->data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3418 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3419 len = r->method_name.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3420 n = sizeof(tests) / sizeof(tests[0]); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3421 test = tests; |
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 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3424 if (len == test->len) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3425 p = r->method_name.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3426 m = test->method; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3427 k = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3428 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3429 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3430 if (*p++ != *m++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3431 goto next; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3432 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3433 } while (--k); |
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 r->method = test->value; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3436 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3437 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3438 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3439 next: |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3440 test++; |
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 } while (--n); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3443 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3444 p = r->method_name.data; |
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 do { |
6732
57148b755320
Allowed '-' in method names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6642
diff
changeset
|
3447 if ((*p < 'A' || *p > 'Z') && *p != '_' && *p != '-') { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3448 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
|
3449 "client sent invalid method: \"%V\"", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3450 &r->method_name); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3451 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3452 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3453 } |
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 p++; |
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 } while (--len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3458 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3459 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3460 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3461 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3462 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3463 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3464 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
|
3465 { |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3466 u_char c, ch; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3467 ngx_uint_t i; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3468 |
7295 | 3469 if (r->schema.len) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3470 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
|
3471 "client sent duplicate :scheme header"); |
6246
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 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3474 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3475 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3476 if (value->len == 0) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3477 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
|
3478 "client sent empty :scheme header"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3479 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3480 return NGX_DECLINED; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3481 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3482 |
7293
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3483 for (i = 0; i < value->len; i++) { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3484 ch = value->data[i]; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3485 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3486 c = (u_char) (ch | 0x20); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3487 if (c >= 'a' && c <= 'z') { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3488 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3489 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3490 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3491 if (((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3492 && i > 0) |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3493 { |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3494 continue; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3495 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3496 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3497 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
|
3498 "client sent invalid :scheme header: \"%V\"", value); |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3499 |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3500 return NGX_DECLINED; |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3501 } |
d588987701f4
HTTP/2: validate client request scheme.
Ruslan Ermilov <ru@nginx.com>
parents:
7241
diff
changeset
|
3502 |
7295 | 3503 r->schema = *value; |
6246
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 return NGX_OK; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3509 static ngx_int_t |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3510 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
|
3511 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3512 ngx_table_elt_t *h; |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3513 ngx_http_header_t *hh; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3514 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3515 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3516 static ngx_str_t host = ngx_string("host"); |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3517 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3518 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3519 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3520 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3521 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3522 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3523 h->hash = ngx_hash(ngx_hash(ngx_hash('h', 'o'), 's'), 't'); |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3524 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3525 h->key.len = host.len; |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3526 h->key.data = host.data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3527 |
7200
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3528 h->value.len = value->len; |
cadb43014c7c
HTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov <ru@nginx.com>
parents:
7192
diff
changeset
|
3529 h->value.data = value->data; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3530 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3531 h->lowcase_key = host.data; |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3532 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3533 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3534 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3535 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3536 h->lowcase_key, h->key.len); |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3537 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3538 if (hh == NULL) { |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3539 return NGX_ERROR; |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3540 } |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3541 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3542 if (hh->handler(r, h, hh->offset) != NGX_OK) { |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3543 /* |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3544 * request has been finalized already |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3545 * in ngx_http_process_host() |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
3546 */ |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3547 return NGX_ABORT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3548 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3549 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3550 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3551 } |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3555 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
|
3556 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3557 u_char *p; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3558 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3559 static const u_char ending[] = " HTTP/2.0"; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3560 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3561 if (r->method_name.len == 0 |
7295 | 3562 || r->schema.len == 0 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3563 || r->unparsed_uri.len == 0) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3564 { |
7106
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3565 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
|
3566 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
|
3567 "client sent no :method header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3568 |
7295 | 3569 } 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
|
3570 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
|
3571 "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
|
3572 |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3573 } else { |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3574 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
|
3575 "client sent no :path header"); |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3576 } |
d77407baccd1
HTTP/2: added logging of 400 (Bad Request) reasons.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7100
diff
changeset
|
3577 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3578 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
|
3579 return NGX_ERROR; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3582 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
|
3583 + r->unparsed_uri.len |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3584 + sizeof(ending) - 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3585 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3586 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
|
3587 if (p == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3588 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
|
3589 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3590 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3591 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3592 r->request_line.data = p; |
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 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
|
3595 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3596 *p++ = ' '; |
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 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
|
3599 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3600 ngx_memcpy(p, ending, sizeof(ending)); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3601 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3602 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
|
3603 "http2 request line: \"%V\"", &r->request_line); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3605 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3606 } |
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 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3610 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
|
3611 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3612 ngx_str_t *val; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3613 ngx_array_t *cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3614 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3615 cookies = r->stream->cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3616 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3617 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3618 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
|
3619 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3620 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3621 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3622 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3623 r->stream->cookies = cookies; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3626 val = ngx_array_push(cookies); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3627 if (val == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3628 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3629 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3630 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3631 val->len = header->value.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3632 val->data = header->value.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3633 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3634 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3635 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3636 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3637 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3638 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3639 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
|
3640 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3641 u_char *buf, *p, *end; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3642 size_t len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3643 ngx_str_t *vals; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3644 ngx_uint_t i; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3645 ngx_array_t *cookies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3646 ngx_table_elt_t *h; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3647 ngx_http_header_t *hh; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3648 ngx_http_core_main_conf_t *cmcf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3649 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3650 static ngx_str_t cookie = ngx_string("cookie"); |
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 cookies = r->stream->cookies; |
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 if (cookies == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3655 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3656 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3657 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3658 vals = cookies->elts; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3659 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3660 i = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3661 len = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3662 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3663 do { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3664 len += vals[i].len + 2; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3665 } while (++i != cookies->nelts); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3666 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3667 len -= 2; |
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 buf = ngx_pnalloc(r->pool, len + 1); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3670 if (buf == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3671 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
|
3672 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3673 } |
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 p = buf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3676 end = buf + len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3677 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3678 for (i = 0; /* void */ ; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3679 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3680 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
|
3681 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3682 if (p == end) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3683 *p = '\0'; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3684 break; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3685 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3686 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3687 *p++ = ';'; *p++ = ' '; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3688 } |
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 h = ngx_list_push(&r->headers_in.headers); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3691 if (h == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3692 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
|
3693 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3694 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3695 |
7209
3dfe9444324b
HTTP/2: precalculate hash for "Cookie".
Maxim Dounin <mdounin@mdounin.ru>
parents:
7208
diff
changeset
|
3696 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
|
3697 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
|
3698 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3699 h->key.len = cookie.len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3700 h->key.data = cookie.data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3701 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3702 h->value.len = len; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3703 h->value.data = buf; |
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 h->lowcase_key = cookie.data; |
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 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
|
3708 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3709 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
|
3710 h->lowcase_key, h->key.len); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3711 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3712 if (hh == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3713 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
|
3714 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3715 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3716 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3717 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
|
3718 /* |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3719 * request has been finalized already |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3720 * in ngx_http_process_multi_header_lines() |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3721 */ |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3722 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3723 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3724 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3725 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3726 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3729 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3730 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
|
3731 { |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3732 ngx_connection_t *fc; |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3733 ngx_http_v2_srv_conf_t *h2scf; |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3734 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
|
3735 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3736 fc = r->connection; |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3737 |
9119
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3738 h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3739 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3740 if (!h2scf->enable && !r->http_connection->addr_conf->http2) { |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3741 ngx_log_error(NGX_LOG_INFO, fc->log, 0, |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3742 "client attempted to request the server name " |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3743 "for which the negotiated protocol is disabled"); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3744 |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3745 ngx_http_finalize_request(r, NGX_HTTP_MISDIRECTED_REQUEST); |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3746 goto failed; |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3747 } |
08ef02ad5c54
HTTP/2: "http2" directive.
Roman Arutyunyan <arut@nginx.com>
parents:
8148
diff
changeset
|
3748 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3749 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
|
3750 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3751 } |
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 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
|
3754 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3755 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3756 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3757 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3758 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3759 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
|
3760 goto failed; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3761 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3762 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3763 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
|
3764 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
|
3765 "client prematurely closed stream"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3766 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3767 r->stream->skip_data = 1; |
9263
388a801e9bb9
Request body: discarded body now treated as no body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9260
diff
changeset
|
3768 r->discard_body = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3769 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3770 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
|
3771 goto failed; |
6246
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 |
6589
78533a74af11
HTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev <vbart@nginx.com>
parents:
6588
diff
changeset
|
3774 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
|
3775 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
|
3776 } |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
3777 |
7569
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3778 h2c = r->stream->connection; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3779 |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3780 h2c->payload_bytes += r->request_length; |
80359395b345
HTTP/2: traffic-based flood detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7568
diff
changeset
|
3781 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3782 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
|
3783 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3784 failed: |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3785 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7335
diff
changeset
|
3786 ngx_http_run_posted_requests(fc); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3787 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3788 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3789 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3790 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
|
3791 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
|
3792 { |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3793 off_t len; |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3794 size_t size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3795 ngx_buf_t *buf; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3796 ngx_int_t rc; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
3797 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
|
3798 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
|
3799 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
|
3800 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
|
3801 ngx_http_v2_connection_t *h2c; |
6246
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 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
|
3804 rb = r->request_body; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3805 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3806 if (stream->skip_data) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3807 r->request_body_no_buffering = 0; |
9254
cb1e214efe41
Request body: provided log action for reading request body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9179
diff
changeset
|
3808 r->connection->log->action = NULL; |
6989
2c4dbcd6f2e4
HTTP/2: reduced difference to HTTP/1.x in reading request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6988
diff
changeset
|
3809 rb->post_handler(r); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3810 return NGX_OK; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3811 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3812 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3813 rb->rest = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3814 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3815 /* set rb->filter_need_buffering */ |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3816 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3817 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
|
3818 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3819 if (rc != NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3820 stream->skip_data = 1; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3821 return rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3822 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3823 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3824 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
|
3825 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
|
3826 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3827 len = r->headers_in.content_length_n; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3828 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3829 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
|
3830 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
|
3831 |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
3832 } else { |
f302c1096f7b
HTTP/2: improved handling of END_STREAM in a separate DATA frame.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7908
diff
changeset
|
3833 len++; |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3834 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3835 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3836 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
|
3837 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3838 /* |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3839 * 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
|
3840 * 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
|
3841 */ |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3842 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3843 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
|
3844 len = h2scf->preread_size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3845 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3846 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
3847 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
|
3848 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
|
3849 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3850 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3851 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3852 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
|
3853 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3854 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
|
3855 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3856 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
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 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3859 buf = stream->preread; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3860 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3861 if (stream->in_closed) { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3862 if (!rb->filter_need_buffering) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3863 r->request_body_no_buffering = 0; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3864 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3865 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3866 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3867 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
|
3868 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
|
3869 ngx_pfree(r->pool, buf->start); |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3870 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3871 } else { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3872 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
|
3873 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3874 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3875 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
|
3876 return rc; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3877 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3878 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3879 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
|
3880 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
|
3881 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3882 return NGX_AGAIN; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3883 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3884 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3885 if (buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3886 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
|
3887 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
|
3888 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3889 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
|
3890 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3891 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
|
3892 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3893 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
|
3894 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3895 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3896 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3897 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
|
3898 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
|
3899 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3900 } else { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3901 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
|
3902 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
|
3903 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3904 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3905 if (size) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3906 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
|
3907 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
|
3908 == NGX_ERROR) |
7760b54d5458
HTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6516
diff
changeset
|
3909 { |
6519
9ac934dd5dd8
HTTP/2: skip data frames in case of internal errors.
Valentin Bartenev <vbart@nginx.com>
parents:
6518
diff
changeset
|
3910 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
|
3911 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
|
3912 } |
6520
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3913 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3914 h2c = stream->connection; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3915 |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3916 if (!h2c->blocked) { |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3917 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
|
3918 stream->skip_data = 1; |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3919 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
|
3920 } |
9070ba416284
HTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev <vbart@nginx.com>
parents:
6519
diff
changeset
|
3921 } |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3922 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3923 stream->recv_window += size; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3924 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3925 |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3926 if (!buf) { |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3927 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
|
3928 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3929 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
3930 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
|
3931 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
|
3932 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3933 return NGX_AGAIN; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3934 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3935 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3936 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3937 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3938 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
|
3939 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
|
3940 { |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3941 size_t n; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3942 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3943 ngx_connection_t *fc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3944 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3945 ngx_http_core_loc_conf_t *clcf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3946 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
3947 fc = r->connection; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3948 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3949 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
3950 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
|
3951 "http2 process request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
3952 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3953 if (size == 0 && !last && !flush) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
3954 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
|
3955 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3956 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3957 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3958 for ( ;; ) { |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3959 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
|
3960 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3961 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
|
3962 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3963 /* 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
|
3964 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3965 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
|
3966 "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
|
3967 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3968 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
|
3969 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3970 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3971 /* update chains */ |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3972 |
7921 | 3973 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
3974 "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
|
3975 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3976 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
|
3977 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3978 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
|
3979 return rc; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3980 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3981 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3982 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
|
3983 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
|
3984 "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
|
3985 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
|
3986 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3987 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3988 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
|
3989 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
|
3990 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3991 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3992 /* 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
|
3993 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3994 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
|
3995 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
3996 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
|
3997 n = size; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3998 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
3999 |
7916
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4000 if (n > 0) { |
29795b697e14
HTTP/2: avoid memcpy() with NULL source and zero length.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7914
diff
changeset
|
4001 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
|
4002 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4003 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4004 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
|
4005 "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
|
4006 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4007 pos += n; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4008 size -= n; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4009 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4010 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
|
4011 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
|
4012 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4013 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4014 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
|
4015 break; |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4016 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4017 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4018 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4019 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
|
4020 "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
|
4021 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4022 if (flush) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4023 rc = ngx_http_v2_filter_request_body(r); |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4024 |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4025 if (rc != NGX_OK) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4026 return rc; |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4027 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4028 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4029 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4030 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
|
4031 break; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4032 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4033 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4034 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
|
4035 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
|
4036 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
|
4037 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4038 if (!flush) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4039 ngx_post_event(fc->read, &ngx_posted_events); |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4040 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4041 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4042 return NGX_AGAIN; |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4043 } |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4044 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4045 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4046 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
|
4047 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
|
4048 } |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4049 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4050 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
|
4051 if (!flush) { |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4052 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
|
4053 } |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4054 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4055 return NGX_OK; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4056 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4057 |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4058 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
|
4059 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
|
4060 } |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4061 |
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4062 r->read_event_handler = ngx_http_block_reading; |
9254
cb1e214efe41
Request body: provided log action for reading request body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9179
diff
changeset
|
4063 r->connection->log->action = NULL; |
7908
0dcec8e5d50a
HTTP/2: reworked body reading to better match HTTP/1.x code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7907
diff
changeset
|
4064 rb->post_handler(r); |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4065 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4066 return NGX_OK; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4067 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4068 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4069 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4070 static ngx_int_t |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4071 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
|
4072 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4073 ngx_buf_t *b, *buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4074 ngx_int_t rc; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4075 ngx_chain_t *cl; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4076 ngx_http_request_body_t *rb; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4077 ngx_http_core_loc_conf_t *clcf; |
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 rb = r->request_body; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4080 buf = rb->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4081 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4082 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
|
4083 cl = NULL; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4084 goto update; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4085 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4086 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4087 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
|
4088 if (cl == NULL) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4089 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4090 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4091 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4092 b = cl->buf; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4093 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4094 ngx_memzero(b, sizeof(ngx_buf_t)); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4095 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4096 if (buf->pos != buf->last) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4097 r->request_length += buf->last - buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4098 rb->received += buf->last - buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4099 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4100 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
|
4101 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
|
4102 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
|
4103 "client intended to send body data " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4104 "larger than declared"); |
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 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4107 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4108 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4109 } else { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4110 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
|
4111 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4112 if (clcf->client_max_body_size |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4113 && rb->received > clcf->client_max_body_size) |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4114 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4115 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
|
4116 "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
|
4117 "%O bytes", rb->received); |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4118 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4119 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4120 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4121 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4122 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4123 b->temporary = 1; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4124 b->pos = buf->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4125 b->last = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4126 b->start = b->pos; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4127 b->end = b->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4128 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4129 buf->pos = buf->last; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4130 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4131 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4132 if (!rb->rest) { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4133 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
|
4134 && 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
|
4135 { |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4136 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
|
4137 "client prematurely closed stream: " |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4138 "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
|
4139 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
|
4140 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4141 return NGX_HTTP_BAD_REQUEST; |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4142 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4143 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4144 b->last_buf = 1; |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4145 rb->last_sent = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4146 } |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4147 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4148 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
|
4149 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
|
4150 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4151 update: |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4152 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4153 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
|
4154 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4155 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
|
4156 (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
|
4157 |
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4158 return rc; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4159 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4160 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4161 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4162 static void |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4163 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
|
4164 { |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4165 size_t window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4166 ngx_buf_t *buf; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4167 ngx_int_t rc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4168 ngx_connection_t *fc; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4169 ngx_http_v2_stream_t *stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4170 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
|
4171 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4172 fc = r->connection; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4173 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4174 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
|
4175 "http2 read client request body handler"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4176 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4177 if (fc->read->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4178 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
|
4179 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4180 fc->timedout = 1; |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4181 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4182 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4183 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
|
4184 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4185 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4186 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4187 if (fc->error) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4188 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
|
4189 "client prematurely closed stream"); |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4190 |
6496
887cca40ba6a
HTTP/2: rewritten handling of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6495
diff
changeset
|
4191 r->stream->skip_data = 1; |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4192 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4193 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
|
4194 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4195 } |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4196 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4197 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
|
4198 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4199 if (rc != NGX_OK && rc != NGX_AGAIN) { |
9259
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
4200 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4201 r->stream->skip_data = 1; |
9263
388a801e9bb9
Request body: discarded body now treated as no body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9260
diff
changeset
|
4202 r->discard_body = 1; |
9259
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
4203 r->request_body->bufs = NULL; |
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
4204 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4205 ngx_http_finalize_request(r, rc); |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4206 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4207 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4208 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4209 if (rc == NGX_OK) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4210 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4211 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4212 |
7924
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4213 if (r->stream->no_flow_control) { |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4214 return; |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4215 } |
d9e009b39596
HTTP/2: optimized processing of small DATA frames.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7923
diff
changeset
|
4216 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4217 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4218 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4219 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4220 |
7922
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4221 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
|
4222 return; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4223 } |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4224 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4225 stream = r->stream; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4226 h2c = stream->connection; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4227 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4228 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
|
4229 |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4230 buf->pos = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4231 buf->last = buf->start; |
e9f402bfe37e
HTTP/2: fixed window updates when buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7921
diff
changeset
|
4232 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4233 window = buf->end - buf->start; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4234 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4235 if (h2c->state.stream == stream) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4236 window -= h2c->state.length; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4237 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4238 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4239 if (window <= stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4240 if (window < stream->recv_window) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4241 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
|
4242 "http2 negative window update"); |
9258
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4243 goto error; |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4244 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4245 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4246 return; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4247 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4248 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4249 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
|
4250 window - stream->recv_window) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4251 == NGX_ERROR) |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4252 { |
9258
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4253 goto error; |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4254 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4255 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4256 stream->recv_window = window; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4257 |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4258 if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { |
9258
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4259 goto error; |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4260 } |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4261 |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4262 return; |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4263 |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4264 error: |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4265 |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4266 stream->skip_data = 1; |
9263
388a801e9bb9
Request body: discarded body now treated as no body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9260
diff
changeset
|
4267 r->discard_body = 1; |
9259
81082b5521dd
Request body: body is now cleared on errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9258
diff
changeset
|
4268 r->request_body->bufs = NULL; |
9258
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4269 |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4270 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4271 return; |
c9550e77186c
Request body: simplified error handling in HTTP/2.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9255
diff
changeset
|
4272 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4273 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4274 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4275 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4276 ngx_int_t |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4277 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
|
4278 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4279 size_t window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4280 ngx_buf_t *buf; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4281 ngx_int_t rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4282 ngx_connection_t *fc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4283 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
|
4284 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
|
4285 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4286 stream = r->stream; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4287 fc = r->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4288 |
7907
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4289 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
|
4290 "http2 read unbuffered request body"); |
51f463301f86
HTTP/2: improved body reading logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
4291 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4292 if (fc->read->timedout) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4293 if (stream->recv_window) { |
9255
208a4adb82ef
Request body: logging of timeouts.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9254
diff
changeset
|
4294 ngx_log_error(NGX_LOG_INFO, fc->log, NGX_ETIMEDOUT, |
208a4adb82ef
Request body: logging of timeouts.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9254
diff
changeset
|
4295 "client timed out"); |
208a4adb82ef
Request body: logging of timeouts.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9254
diff
changeset
|
4296 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4297 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4298 fc->timedout = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4299 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4300 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
|
4301 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4302 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4303 fc->read->timedout = 0; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4304 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4305 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4306 if (fc->error) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4307 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4308 return NGX_HTTP_BAD_REQUEST; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4309 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4310 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4311 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
|
4312 |
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4313 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
|
4314 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4315 return rc; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4316 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4317 |
7923
4775c1d27378
HTTP/2: fixed timers left after request body reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7922
diff
changeset
|
4318 if (rc == NGX_OK) { |
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 |
7914
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4322 if (r->request_body->rest == 0) { |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4323 return NGX_AGAIN; |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4324 } |
9cf043a5d9ca
Request body: reading body buffering in filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7910
diff
changeset
|
4325 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4326 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
|
4327 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4328 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4329 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4330 buf = r->request_body->buf; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4331 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4332 buf->pos = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4333 buf->last = buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4334 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4335 window = buf->end - buf->start; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4336 h2c = stream->connection; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4337 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4338 if (h2c->state.stream == stream) { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4339 window -= h2c->state.length; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4340 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4341 |
6566
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4342 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
|
4343 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
|
4344 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
|
4345 "http2 negative window update"); |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4346 stream->skip_data = 1; |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4347 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
|
4348 } |
ce94f07d5082
HTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev <vbart@nginx.com>
parents:
6520
diff
changeset
|
4349 |
6497
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4350 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4351 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4352 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4353 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
|
4354 window - stream->recv_window) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4355 == NGX_ERROR) |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4356 { |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4357 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4358 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
|
4359 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4360 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4361 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
|
4362 stream->skip_data = 1; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4363 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
|
4364 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4365 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4366 stream->recv_window = window; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4367 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4368 return NGX_AGAIN; |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4369 } |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4370 |
9d66d7ed2abb
HTTP/2: support for unbuffered upload of request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6496
diff
changeset
|
4371 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4372 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4373 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
|
4374 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
|
4375 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4376 ngx_event_t *rev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4377 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4378 |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4379 if (stream->rst_sent) { |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4380 return NGX_OK; |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4381 } |
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4382 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4383 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
|
4384 == NGX_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4385 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4386 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4387 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4388 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4389 stream->rst_sent = 1; |
6588
dc5eaf998b96
HTTP/2: prevented double termination of a stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6587
diff
changeset
|
4390 stream->skip_data = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4391 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4392 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4393 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4394 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4395 rev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4396 rev->handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4397 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4398 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4399 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4400 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4401 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4402 void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4403 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
|
4404 { |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4405 ngx_pool_t *pool; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4406 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4407 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4408 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4409 ngx_http_v2_connection_t *h2c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4410 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4411 h2c = stream->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4412 node = stream->node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4413 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4414 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4415 "http2 close stream %ui, queued %ui, processing %ui", |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4416 node->id, stream->queued, h2c->processing); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4417 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4418 fc = stream->request->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4419 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4420 if (stream->queued) { |
7610
82c1339e2637
HTTP/2: fixed socket leak with queued frames (ticket #1689).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7571
diff
changeset
|
4421 fc->error = 1; |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4422 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
|
4423 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
|
4424 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4425 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4426 |
6495
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4427 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
|
4428 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4429 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
|
4430 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
|
4431 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
|
4432 : 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
|
4433 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4434 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4435 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
|
4436 } |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4437 |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4438 } 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
|
4439 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
|
4440 != NGX_OK) |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4441 { |
92464ebace8e
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
4442 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
|
4443 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4444 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4445 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4446 |
6410
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4447 if (h2c->state.stream == stream) { |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4448 h2c->state.stream = NULL; |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4449 } |
c6ccc1ea9450
HTTP/2: cleaned up state while closing stream.
Valentin Bartenev <vbart@nginx.com>
parents:
6376
diff
changeset
|
4450 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4451 node->stream = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4452 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4453 ngx_queue_insert_tail(&h2c->closed, &node->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4454 h2c->closed_nodes++; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4455 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4456 /* |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4457 * 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
|
4458 * 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
|
4459 * |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4460 * 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
|
4461 * 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
|
4462 */ |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4463 pool = stream->pool; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4464 |
7548
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4465 h2c->frames -= stream->frames; |
99257b06b0bd
HTTP/2: limited number of DATA frames.
Ruslan Ermilov <ru@nginx.com>
parents:
7547
diff
changeset
|
4466 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4467 ngx_http_free_request(stream->request, rc); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4468 |
6411
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4469 if (pool != h2c->state.pool) { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4470 ngx_destroy_pool(pool); |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4471 |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4472 } else { |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4473 /* 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
|
4474 h2c->state.keep_pool = 0; |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4475 } |
8ec349bb60b2
HTTP/2: always use temporary pool for processing headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6410
diff
changeset
|
4476 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4477 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4478 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4479 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4480 ngx_del_timer(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4481 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4482 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4483 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4484 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4485 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4486 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4487 ev = fc->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4488 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4489 if (ev->timer_set) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4490 ngx_del_timer(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4491 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4492 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4493 if (ev->posted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4494 ngx_delete_posted_event(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4495 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4496 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4497 fc->data = h2c->free_fake_connections; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4498 h2c->free_fake_connections = fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4499 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4500 h2c->processing--; |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4501 |
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4502 if (h2c->processing || h2c->blocked) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4503 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4504 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4505 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4506 ev = h2c->connection->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4507 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4508 ev->handler = ngx_http_v2_handle_connection_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4509 ngx_post_event(ev, &ngx_posted_events); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4510 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4511 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4512 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4513 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4514 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
|
4515 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4516 ngx_connection_t *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4517 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4518 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4519 fc = ev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4520 r = fc->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4521 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4522 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
|
4523 "http2 close stream handler"); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4524 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4525 if (ev->timedout) { |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4526 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
|
4527 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4528 fc->timedout = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4529 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4530 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
|
4531 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4532 } |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4533 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4534 ngx_http_v2_close_stream(r->stream, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4535 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4536 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4537 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4538 static void |
7611
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4539 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
|
4540 { |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4541 ngx_connection_t *fc; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4542 ngx_http_request_t *r; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4543 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4544 fc = ev->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4545 r = fc->data; |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4546 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4547 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
|
4548 "http2 retry close stream handler"); |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4549 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4550 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
|
4551 } |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4552 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4553 |
8e64e11aaca0
HTTP/2: introduced separate handler to retry stream close.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7610
diff
changeset
|
4554 static void |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4555 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
|
4556 { |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4557 ngx_connection_t *c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4558 ngx_http_v2_connection_t *h2c; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4559 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4560 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
|
4561 "http2 handle connection handler"); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4562 |
6957
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4563 c = rev->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4564 h2c = c->data; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4565 |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4566 if (c->error) { |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4567 ngx_http_v2_finalize_connection(h2c, 0); |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4568 return; |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4569 } |
83bae3d354ab
HTTP/2: fixed connection finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6956
diff
changeset
|
4570 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4571 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4572 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4573 if (rev->ready) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4574 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4575 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4576 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4577 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4578 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
|
4579 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
|
4580 return; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4581 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4582 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4583 ngx_http_v2_handle_connection(c->data); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4584 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4585 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4586 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4587 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4588 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
|
4589 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4590 ngx_connection_t *c; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4591 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4592 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
|
4593 ngx_http_core_loc_conf_t *clcf; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4594 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4595 c = rev->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4596 h2c = c->data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4597 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4598 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
|
4599 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4600 if (rev->timedout || c->close) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4601 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
|
4602 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4603 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4604 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4605 #if (NGX_HAVE_KQUEUE) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4606 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4607 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4608 if (rev->pending_eof) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4609 c->log->handler = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4610 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
|
4611 "kevent() reported that client %V closed " |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4612 "idle connection", &c->addr_text); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4613 #if (NGX_HTTP_SSL) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4614 if (c->ssl) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4615 c->ssl->no_send_shutdown = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4616 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4617 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4618 ngx_http_close_connection(c); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4619 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4620 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4621 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4622 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4623 #endif |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4624 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4625 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
|
4626 ngx_http_core_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4627 |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4628 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
|
4629 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
|
4630 "http2 flood detected"); |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4631 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
|
4632 return; |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4633 } |
e7f19d268c72
HTTP/2: limit the number of idle state switches.
Ruslan Ermilov <ru@nginx.com>
parents:
7377
diff
changeset
|
4634 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4635 c->destroyed = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4636 ngx_reusable_connection(c, 0); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4637 |
7772
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4638 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
|
4639 ngx_http_v2_module); |
f790816a0e87
HTTP/2: removed http2_idle_timeout and http2_max_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7771
diff
changeset
|
4640 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4641 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
|
4642 if (h2c->pool == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4643 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
|
4644 return; |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4647 c->write->handler = ngx_http_v2_write_handler; |
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 rev->handler = ngx_http_v2_read_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4650 ngx_http_v2_read_handler(rev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4651 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4652 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4653 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4654 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4655 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
|
4656 ngx_uint_t status) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4657 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4658 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4659 ngx_event_t *ev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4660 ngx_connection_t *c, *fc; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4661 ngx_http_request_t *r; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4662 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4663 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4664 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4665 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4666 c = h2c->connection; |
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 h2c->blocked = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4669 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4670 if (!c->error && !h2c->goaway) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4671 h2c->goaway = 1; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4672 |
6778
5e95b9fb33b7
HTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev <vbart@nginx.com>
parents:
6732
diff
changeset
|
4673 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
|
4674 (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
|
4675 } |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4676 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4677 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4678 if (!h2c->processing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4679 goto done; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4680 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4681 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4682 c->read->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4683 c->write->handler = ngx_http_empty_handler; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4684 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4685 h2c->last_out = NULL; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4686 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4687 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
|
4688 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4689 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4690 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4691 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4692 for (i = 0; i < size; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4693 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4694 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
|
4695 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4696 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4697 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4698 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4699 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4700 |
6833
3834951e32ab
HTTP/2: fixed posted streams handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6805
diff
changeset
|
4701 stream->waiting = 0; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4702 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4703 r = stream->request; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4704 fc = r->connection; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4705 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4706 fc->error = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4707 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4708 if (stream->queued) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4709 stream->queued = 0; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4710 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4711 ev = fc->write; |
6956
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4712 ev->active = 0; |
9b5f31fdb850
HTTP/2: fixed stream finalization.
Valentin Bartenev <vbart@nginx.com>
parents:
6955
diff
changeset
|
4713 ev->ready = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4714 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4715 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4716 ev = fc->read; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4717 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4718 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4719 ev->eof = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4720 ev->handler(ev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4721 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4722 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4723 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4724 h2c->blocked = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4725 |
9121
262c01782566
HTTP/2: removed server push (ticket #2432).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9119
diff
changeset
|
4726 if (h2c->processing) { |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4727 c->error = 1; |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4728 return; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4729 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4730 |
7673
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4731 done: |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4732 |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4733 if (c->error) { |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4734 ngx_http_close_connection(c); |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4735 return; |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4736 } |
c5840ca2063d
HTTP/2: lingering close after GOAWAY.
Ruslan Ermilov <ru@nginx.com>
parents:
7656
diff
changeset
|
4737 |
7738
554c6ae25ffc
SSL: fixed non-working SSL shutdown on lingering close.
Ruslan Ermilov <ru@nginx.com>
parents:
7711
diff
changeset
|
4738 ngx_http_v2_lingering_close(c); |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4739 } |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4742 static ngx_int_t |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4743 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
|
4744 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4745 ngx_uint_t i, size; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4746 ngx_event_t *wev; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4747 ngx_http_v2_node_t *node; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4748 ngx_http_v2_stream_t *stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4749 ngx_http_v2_srv_conf_t *h2scf; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4750 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4751 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
|
4752 ngx_http_v2_module); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4753 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4754 size = ngx_http_v2_index_size(h2scf); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4755 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4756 for (i = 0; i < size; i++) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4757 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4758 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
|
4759 stream = node->stream; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4760 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4761 if (stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4762 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4763 } |
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 if (delta > 0 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4766 && stream->send_window |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4767 > (ssize_t) (NGX_HTTP_V2_MAX_WINDOW - delta)) |
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 if (ngx_http_v2_terminate_stream(h2c, stream, |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4770 NGX_HTTP_V2_FLOW_CTRL_ERROR) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4771 == NGX_ERROR) |
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 return NGX_ERROR; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4774 } |
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 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4777 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4778 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4779 stream->send_window += delta; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4780 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4781 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
|
4782 "http2:%ui adjusted window: %z", |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4783 node->id, stream->send_window); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4784 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4785 if (stream->send_window > 0 && stream->exhausted) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4786 stream->exhausted = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4787 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4788 wev = stream->request->connection->write; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4789 |
6412
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4790 wev->active = 0; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4791 wev->ready = 1; |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4792 |
4ba91a4c66a3
HTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev <vbart@nginx.com>
parents:
6411
diff
changeset
|
4793 if (!wev->delayed) { |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4794 wev->handler(wev); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4795 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4796 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4797 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4798 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4799 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4800 return NGX_OK; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4801 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4802 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4803 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4804 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4805 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
|
4806 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
|
4807 { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4808 ngx_queue_t *children, *q; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4809 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
|
4810 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4811 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
|
4812 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4813 if (parent == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4814 parent = NGX_HTTP_V2_ROOT; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4815 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4816 if (depend != 0) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4817 exclusive = 0; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4818 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4819 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4820 node->rank = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4821 node->rel_weight = (1.0 / 256) * node->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4822 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4823 children = &h2c->dependencies; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4824 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4825 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4826 if (node->parent != NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4827 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4828 for (next = parent->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4829 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
|
4830 next = next->parent) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4831 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4832 if (next != node) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4833 continue; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4834 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4835 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4836 ngx_queue_remove(&parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4837 ngx_queue_insert_after(&node->queue, &parent->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4838 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4839 parent->parent = node->parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4840 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4841 if (node->parent == NGX_HTTP_V2_ROOT) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4842 parent->rank = 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4843 parent->rel_weight = (1.0 / 256) * parent->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4844 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4845 } else { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4846 parent->rank = node->parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4847 parent->rel_weight = (node->parent->rel_weight / 256) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4848 * parent->weight; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4849 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4850 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4851 if (!exclusive) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4852 ngx_http_v2_node_children_update(parent); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4853 } |
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 break; |
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 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4858 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4859 node->rank = parent->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4860 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
|
4861 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4862 if (parent->stream == NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4863 ngx_queue_remove(&parent->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4864 ngx_queue_insert_tail(&h2c->closed, &parent->reuse); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4865 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4866 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4867 children = &parent->children; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4868 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4869 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4870 if (exclusive) { |
6272
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4871 for (q = ngx_queue_head(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4872 q != ngx_queue_sentinel(children); |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4873 q = ngx_queue_next(q)) |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4874 { |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4875 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
|
4876 child->parent = node; |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4877 } |
b6a665bf858a
HTTP/2: fix indirect reprioritization.
Piotr Sikora <piotrsikora@google.com>
parents:
6271
diff
changeset
|
4878 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4879 ngx_queue_add(&node->children, children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4880 ngx_queue_init(children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4881 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4882 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4883 if (node->parent != NULL) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4884 ngx_queue_remove(&node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4885 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4886 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4887 ngx_queue_insert_tail(children, &node->queue); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4888 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4889 node->parent = parent; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4890 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4891 ngx_http_v2_node_children_update(node); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4892 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4893 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4894 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4895 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4896 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
|
4897 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4898 ngx_queue_t *q; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4899 ngx_http_v2_node_t *child; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4900 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4901 for (q = ngx_queue_head(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4902 q != ngx_queue_sentinel(&node->children); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4903 q = ngx_queue_next(q)) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4904 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4905 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
|
4906 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4907 child->rank = node->rank + 1; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4908 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
|
4909 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4910 ngx_http_v2_node_children_update(child); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4911 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4912 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4913 |
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 static void |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4916 ngx_http_v2_pool_cleanup(void *data) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4917 { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4918 ngx_http_v2_connection_t *h2c = data; |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4919 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4920 if (h2c->state.pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4921 ngx_destroy_pool(h2c->state.pool); |
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 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4924 if (h2c->pool) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4925 ngx_destroy_pool(h2c->pool); |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4926 } |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4927 } |