Mercurial > hg > nginx-quic
annotate src/http/v3/ngx_http_v3_filter_module.c @ 8605:4ca8035c19a4 quic
Merged with the default branch.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 08 Sep 2021 15:53:00 +0300 |
parents | 07f90cb79fec |
children | 2cb697e7d77f |
rev | line source |
---|---|
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
2 /* |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Roman Arutyunyan |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
4 * Copyright (C) Nginx, Inc. |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
5 */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
6 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
7 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
11 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
12 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
13 /* static table indices */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
14 #define NGX_HTTP_V3_HEADER_AUTHORITY 0 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
15 #define NGX_HTTP_V3_HEADER_PATH_ROOT 1 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
16 #define NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
17 #define NGX_HTTP_V3_HEADER_DATE 6 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
18 #define NGX_HTTP_V3_HEADER_LAST_MODIFIED 10 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
19 #define NGX_HTTP_V3_HEADER_LOCATION 12 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
20 #define NGX_HTTP_V3_HEADER_METHOD_GET 17 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
21 #define NGX_HTTP_V3_HEADER_SCHEME_HTTP 22 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
22 #define NGX_HTTP_V3_HEADER_SCHEME_HTTPS 23 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
23 #define NGX_HTTP_V3_HEADER_STATUS_200 25 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
24 #define NGX_HTTP_V3_HEADER_ACCEPT_ENCODING 31 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
25 #define NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN 53 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
26 #define NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING 59 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
27 #define NGX_HTTP_V3_HEADER_ACCEPT_LANGUAGE 72 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
28 #define NGX_HTTP_V3_HEADER_SERVER 92 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
29 #define NGX_HTTP_V3_HEADER_USER_AGENT 95 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
30 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
31 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
32 typedef struct { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
33 ngx_chain_t *free; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
34 ngx_chain_t *busy; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
35 } ngx_http_v3_filter_ctx_t; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
36 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
37 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
38 static ngx_int_t ngx_http_v3_header_filter(ngx_http_request_t *r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
39 static ngx_int_t ngx_http_v3_push_resources(ngx_http_request_t *r, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
40 ngx_chain_t ***out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
41 static ngx_int_t ngx_http_v3_push_resource(ngx_http_request_t *r, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
42 ngx_str_t *path, ngx_chain_t ***out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
43 static ngx_int_t ngx_http_v3_create_push_request( |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
44 ngx_http_request_t *pr, ngx_str_t *path, uint64_t push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
45 static ngx_int_t ngx_http_v3_set_push_header(ngx_http_request_t *r, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
46 const char *name, ngx_str_t *value); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
47 static void ngx_http_v3_push_request_handler(ngx_event_t *ev); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
48 static ngx_chain_t *ngx_http_v3_create_push_promise(ngx_http_request_t *r, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
49 ngx_str_t *path, uint64_t push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
50 static ngx_int_t ngx_http_v3_body_filter(ngx_http_request_t *r, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
51 ngx_chain_t *in); |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
52 static ngx_chain_t *ngx_http_v3_create_trailers(ngx_http_request_t *r, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
53 ngx_http_v3_filter_ctx_t *ctx); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
54 static ngx_int_t ngx_http_v3_filter_init(ngx_conf_t *cf); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
55 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
56 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
57 static ngx_http_module_t ngx_http_v3_filter_module_ctx = { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
58 NULL, /* preconfiguration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
59 ngx_http_v3_filter_init, /* postconfiguration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
60 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
61 NULL, /* create main configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
62 NULL, /* init main configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
63 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
64 NULL, /* create server configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
65 NULL, /* merge server configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
66 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
67 NULL, /* create location configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
68 NULL /* merge location configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
69 }; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
70 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
71 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
72 ngx_module_t ngx_http_v3_filter_module = { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
73 NGX_MODULE_V1, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
74 &ngx_http_v3_filter_module_ctx, /* module context */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
75 NULL, /* module directives */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
76 NGX_HTTP_MODULE, /* module type */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
77 NULL, /* init master */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
78 NULL, /* init module */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
79 NULL, /* init process */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
80 NULL, /* init thread */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
81 NULL, /* exit thread */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
82 NULL, /* exit process */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
83 NULL, /* exit master */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
84 NGX_MODULE_V1_PADDING |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
85 }; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
86 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
87 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
88 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
89 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
90 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
91 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
92 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
93 ngx_http_v3_header_filter(ngx_http_request_t *r) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
94 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
95 u_char *p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
96 size_t len, n; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
97 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
98 ngx_str_t host; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
99 ngx_uint_t i, port; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
100 ngx_chain_t *out, *hl, *cl, **ll; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
101 ngx_list_part_t *part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
102 ngx_table_elt_t *header; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
103 ngx_connection_t *c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
104 ngx_http_v3_filter_ctx_t *ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
105 ngx_http_core_loc_conf_t *clcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
106 ngx_http_core_srv_conf_t *cscf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
107 u_char addr[NGX_SOCKADDR_STRLEN]; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
108 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
109 if (r->http_version != NGX_HTTP_VERSION_30) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
110 return ngx_http_next_header_filter(r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
111 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
112 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
113 if (r->header_sent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
114 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
115 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
116 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
117 r->header_sent = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
118 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
119 if (r != r->main) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
120 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
121 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
122 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
123 if (r->method == NGX_HTTP_HEAD) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
124 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
125 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
126 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
127 if (r->headers_out.last_modified_time != -1) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
128 if (r->headers_out.status != NGX_HTTP_OK |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
129 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
130 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
131 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
132 r->headers_out.last_modified_time = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
133 r->headers_out.last_modified = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
134 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
135 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
136 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
137 if (r->headers_out.status == NGX_HTTP_NO_CONTENT) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
138 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
139 ngx_str_null(&r->headers_out.content_type); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
140 r->headers_out.last_modified_time = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
141 r->headers_out.last_modified = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
142 r->headers_out.content_length = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
143 r->headers_out.content_length_n = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
144 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
145 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
146 if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
147 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
148 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
149 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
150 c = r->connection; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
151 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
152 out = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
153 ll = &out; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
154 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
155 if ((c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
156 && r->method != NGX_HTTP_HEAD) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
157 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
158 if (ngx_http_v3_push_resources(r, &ll) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
159 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
160 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
161 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
162 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
163 len = ngx_http_v3_encode_field_section_prefix(NULL, 0, 0, 0); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
164 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
165 if (r->headers_out.status == NGX_HTTP_OK) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
166 len += ngx_http_v3_encode_field_ri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
167 NGX_HTTP_V3_HEADER_STATUS_200); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
168 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
169 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
170 len += ngx_http_v3_encode_field_lri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
171 NGX_HTTP_V3_HEADER_STATUS_200, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
172 NULL, 3); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
173 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
174 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
175 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
176 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
177 if (r->headers_out.server == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
178 if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
179 n = sizeof(NGINX_VER) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
180 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
181 } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
182 n = sizeof(NGINX_VER_BUILD) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
183 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
184 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
185 n = sizeof("nginx") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
186 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
187 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
188 len += ngx_http_v3_encode_field_lri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
189 NGX_HTTP_V3_HEADER_SERVER, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
190 NULL, n); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
191 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
192 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
193 if (r->headers_out.date == NULL) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
194 len += ngx_http_v3_encode_field_lri(NULL, 0, NGX_HTTP_V3_HEADER_DATE, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
195 NULL, ngx_cached_http_time.len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
196 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
197 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
198 if (r->headers_out.content_type.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
199 n = r->headers_out.content_type.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
200 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
201 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
202 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
203 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
204 n += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
205 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
206 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
207 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
208 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
209 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
210 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
211 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
212 if (r->headers_out.content_length == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
213 if (r->headers_out.content_length_n > 0) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
214 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
215 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
216 NULL, NGX_OFF_T_LEN); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
217 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
218 } else if (r->headers_out.content_length_n == 0) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
219 len += ngx_http_v3_encode_field_ri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
220 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
221 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
222 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
223 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
224 if (r->headers_out.last_modified == NULL |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
225 && r->headers_out.last_modified_time != -1) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
226 { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
227 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
228 NGX_HTTP_V3_HEADER_LAST_MODIFIED, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
229 sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
230 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
231 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
232 if (r->headers_out.location |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
233 && r->headers_out.location->value.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
234 && r->headers_out.location->value.data[0] == '/' |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
235 && clcf->absolute_redirect) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
236 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
237 r->headers_out.location->hash = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
238 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
239 if (clcf->server_name_in_redirect) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
240 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
241 host = cscf->server_name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
242 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
243 } else if (r->headers_in.server.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
244 host = r->headers_in.server; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
245 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
246 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
247 host.len = NGX_SOCKADDR_STRLEN; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
248 host.data = addr; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
249 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
250 if (ngx_connection_local_sockaddr(c, &host, 0) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
251 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
252 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
253 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
254 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
255 port = ngx_inet_get_port(c->local_sockaddr); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
256 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
257 n = sizeof("https://") - 1 + host.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
258 + r->headers_out.location->value.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
259 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
260 if (clcf->port_in_redirect) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
261 port = (port == 443) ? 0 : port; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
262 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
263 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
264 port = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
265 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
266 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
267 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
268 n += sizeof(":65535") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
269 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
270 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
271 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
272 NGX_HTTP_V3_HEADER_LOCATION, NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
273 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
274 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
275 ngx_str_null(&host); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
276 port = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
277 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
278 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
279 #if (NGX_HTTP_GZIP) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
280 if (r->gzip_vary) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
281 if (clcf->gzip_vary) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
282 len += ngx_http_v3_encode_field_ri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
283 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
284 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
285 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
286 r->gzip_vary = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
287 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
288 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
289 #endif |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
290 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
291 part = &r->headers_out.headers.part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
292 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
293 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
294 for (i = 0; /* void */; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
295 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
296 if (i >= part->nelts) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
297 if (part->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
298 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
299 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
300 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
301 part = part->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
302 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
303 i = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
304 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
305 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
306 if (header[i].hash == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
307 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
308 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
309 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
310 len += ngx_http_v3_encode_field_l(NULL, &header[i].key, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
311 &header[i].value); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
312 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
313 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
314 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 header len:%uz", len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
315 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
316 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
317 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
318 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
319 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
320 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
321 b->last = (u_char *) ngx_http_v3_encode_field_section_prefix(b->last, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
322 0, 0, 0); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
323 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
324 if (r->headers_out.status == NGX_HTTP_OK) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
325 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
326 NGX_HTTP_V3_HEADER_STATUS_200); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
327 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
328 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
329 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
330 NGX_HTTP_V3_HEADER_STATUS_200, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
331 NULL, 3); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
332 b->last = ngx_sprintf(b->last, "%03ui", r->headers_out.status); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
333 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
334 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
335 if (r->headers_out.server == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
336 if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
337 p = (u_char *) NGINX_VER; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
338 n = sizeof(NGINX_VER) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
339 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
340 } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
341 p = (u_char *) NGINX_VER_BUILD; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
342 n = sizeof(NGINX_VER_BUILD) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
343 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
344 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
345 p = (u_char *) "nginx"; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
346 n = sizeof("nginx") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
347 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
348 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
349 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
350 NGX_HTTP_V3_HEADER_SERVER, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
351 p, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
352 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
353 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
354 if (r->headers_out.date == NULL) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
355 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
356 NGX_HTTP_V3_HEADER_DATE, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
357 ngx_cached_http_time.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
358 ngx_cached_http_time.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
359 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
360 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
361 if (r->headers_out.content_type.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
362 n = r->headers_out.content_type.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
363 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
364 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
365 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
366 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
367 n += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
368 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
369 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
370 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
371 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
372 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
373 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
374 p = b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
375 b->last = ngx_cpymem(b->last, r->headers_out.content_type.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
376 r->headers_out.content_type.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
377 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
378 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
379 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
380 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
381 b->last = ngx_cpymem(b->last, "; charset=", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
382 sizeof("; charset=") - 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
383 b->last = ngx_cpymem(b->last, r->headers_out.charset.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
384 r->headers_out.charset.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
385 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
386 /* update r->headers_out.content_type for possible logging */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
387 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
388 r->headers_out.content_type.len = b->last - p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
389 r->headers_out.content_type.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
390 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
391 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
392 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
393 if (r->headers_out.content_length == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
394 if (r->headers_out.content_length_n > 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
395 p = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
396 n = p - b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
397 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
398 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
399 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
400 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
401 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
402 b->last = ngx_sprintf(b->last, "%O", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
403 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
404 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
405 } else if (r->headers_out.content_length_n == 0) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
406 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
407 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
408 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
409 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
410 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
411 if (r->headers_out.last_modified == NULL |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
412 && r->headers_out.last_modified_time != -1) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
413 { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
414 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
415 NGX_HTTP_V3_HEADER_LAST_MODIFIED, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
416 sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
417 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
418 b->last = ngx_http_time(b->last, r->headers_out.last_modified_time); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
419 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
420 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
421 if (host.data) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
422 n = sizeof("https://") - 1 + host.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
423 + r->headers_out.location->value.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
424 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
425 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
426 n += ngx_sprintf(b->last, ":%ui", port) - b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
427 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
428 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
429 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
430 NGX_HTTP_V3_HEADER_LOCATION, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
431 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
432 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
433 p = b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
434 b->last = ngx_cpymem(b->last, "https://", sizeof("https://") - 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
435 b->last = ngx_cpymem(b->last, host.data, host.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
436 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
437 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
438 b->last = ngx_sprintf(b->last, ":%ui", port); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
439 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
440 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
441 b->last = ngx_cpymem(b->last, r->headers_out.location->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
442 r->headers_out.location->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
443 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
444 /* update r->headers_out.location->value for possible logging */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
445 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
446 r->headers_out.location->value.len = b->last - p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
447 r->headers_out.location->value.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
448 ngx_str_set(&r->headers_out.location->key, "Location"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
449 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
450 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
451 #if (NGX_HTTP_GZIP) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
452 if (r->gzip_vary) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
453 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
454 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
455 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
456 #endif |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
457 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
458 part = &r->headers_out.headers.part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
459 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
460 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
461 for (i = 0; /* void */; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
462 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
463 if (i >= part->nelts) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
464 if (part->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
465 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
466 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
467 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
468 part = part->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
469 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
470 i = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
471 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
472 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
473 if (header[i].hash == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
474 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
475 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
476 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
477 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
478 &header[i].key, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
479 &header[i].value); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
480 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
481 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
482 if (r->header_only) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
483 b->last_buf = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
484 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
485 |
8543
07f90cb79fec
HTTP/3: use request pool instead of connection pool.
Roman Arutyunyan <arut@nginx.com>
parents:
8542
diff
changeset
|
486 cl = ngx_alloc_chain_link(r->pool); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
487 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
488 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
489 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
490 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
491 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
492 cl->next = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
493 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
494 n = b->last - b->pos; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
495 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
496 len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_HEADERS) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
497 + ngx_http_v3_encode_varlen_int(NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
498 |
8543
07f90cb79fec
HTTP/3: use request pool instead of connection pool.
Roman Arutyunyan <arut@nginx.com>
parents:
8542
diff
changeset
|
499 b = ngx_create_temp_buf(r->pool, len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
500 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
501 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
502 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
503 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
504 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
505 NGX_HTTP_V3_FRAME_HEADERS); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
506 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
507 |
8543
07f90cb79fec
HTTP/3: use request pool instead of connection pool.
Roman Arutyunyan <arut@nginx.com>
parents:
8542
diff
changeset
|
508 hl = ngx_alloc_chain_link(r->pool); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
509 if (hl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
510 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
511 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
512 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
513 hl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
514 hl->next = cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
515 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
516 *ll = hl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
517 ll = &cl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
518 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
519 if (r->headers_out.content_length_n >= 0 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
520 && !r->header_only && !r->expect_trailers) |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
521 { |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
522 len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_DATA) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
523 + ngx_http_v3_encode_varlen_int(NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
524 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
525 |
8543
07f90cb79fec
HTTP/3: use request pool instead of connection pool.
Roman Arutyunyan <arut@nginx.com>
parents:
8542
diff
changeset
|
526 b = ngx_create_temp_buf(r->pool, len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
527 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
528 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
529 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
530 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
531 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
532 NGX_HTTP_V3_FRAME_DATA); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
533 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
534 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
535 |
8543
07f90cb79fec
HTTP/3: use request pool instead of connection pool.
Roman Arutyunyan <arut@nginx.com>
parents:
8542
diff
changeset
|
536 cl = ngx_alloc_chain_link(r->pool); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
537 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
538 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
539 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
540 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
541 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
542 cl->next = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
543 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
544 *ll = cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
545 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
546 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
547 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_filter_ctx_t)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
548 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
549 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
550 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
551 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
552 ngx_http_set_ctx(r, ctx, ngx_http_v3_filter_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
553 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
554 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
555 return ngx_http_write_filter(r, out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
556 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
557 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
558 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
559 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
560 ngx_http_v3_push_resources(ngx_http_request_t *r, ngx_chain_t ***out) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
561 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
562 u_char *start, *end, *last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
563 ngx_str_t path; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
564 ngx_int_t rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
565 ngx_uint_t i, push; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
566 ngx_table_elt_t **h; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
567 ngx_http_v3_loc_conf_t *h3lcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
568 ngx_http_complex_value_t *pushes; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
569 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
570 h3lcf = ngx_http_get_module_loc_conf(r, ngx_http_v3_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
571 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
572 if (h3lcf->pushes) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
573 pushes = h3lcf->pushes->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
574 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
575 for (i = 0; i < h3lcf->pushes->nelts; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
576 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
577 if (ngx_http_complex_value(r, &pushes[i], &path) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
578 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
579 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
580 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
581 if (path.len == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
582 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
583 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
584 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
585 if (path.len == 3 && ngx_strncmp(path.data, "off", 3) == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
586 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
587 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
588 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
589 rc = ngx_http_v3_push_resource(r, &path, out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
590 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
591 if (rc == NGX_ERROR) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
592 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
593 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
594 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
595 if (rc == NGX_ABORT) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
596 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
597 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
598 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
599 /* NGX_OK, NGX_DECLINED */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
600 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
601 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
602 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
603 if (!h3lcf->push_preload) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
604 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
605 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
606 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
607 h = r->headers_out.link.elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
608 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
609 for (i = 0; i < r->headers_out.link.nelts; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
610 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
611 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
612 "http3 parse link: \"%V\"", &h[i]->value); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
613 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
614 start = h[i]->value.data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
615 end = h[i]->value.data + h[i]->value.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
616 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
617 next_link: |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
618 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
619 while (start < end && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
620 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
621 if (start == end || *start++ != '<') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
622 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
623 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
624 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
625 while (start < end && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
626 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
627 for (last = start; last < end && *last != '>'; last++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
628 /* void */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
629 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
630 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
631 if (last == start || last == end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
632 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
633 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
634 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
635 path.len = last - start; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
636 path.data = start; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
637 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
638 start = last + 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
639 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
640 while (start < end && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
641 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
642 if (start == end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
643 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
644 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
645 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
646 if (*start == ',') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
647 start++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
648 goto next_link; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
649 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
650 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
651 if (*start++ != ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
652 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
653 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
654 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
655 last = ngx_strlchr(start, end, ','); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
656 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
657 if (last == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
658 last = end; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
659 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
660 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
661 push = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
662 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
663 for ( ;; ) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
664 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
665 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
666 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
667 if (last - start >= 6 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
668 && ngx_strncasecmp(start, (u_char *) "nopush", 6) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
669 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
670 start += 6; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
671 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
672 if (start == last || *start == ' ' || *start == ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
673 push = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
674 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
675 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
676 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
677 goto next_param; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
678 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
679 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
680 if (last - start >= 11 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
681 && ngx_strncasecmp(start, (u_char *) "rel=preload", 11) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
682 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
683 start += 11; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
684 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
685 if (start == last || *start == ' ' || *start == ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
686 push = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
687 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
688 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
689 goto next_param; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
690 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
691 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
692 if (last - start >= 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
693 && ngx_strncasecmp(start, (u_char *) "rel=", 4) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
694 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
695 start += 4; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
696 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
697 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
698 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
699 if (start == last || *start++ != '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
700 goto next_param; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
701 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
702 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
703 for ( ;; ) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
704 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
705 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
706 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
707 if (last - start >= 7 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
708 && ngx_strncasecmp(start, (u_char *) "preload", 7) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
709 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
710 start += 7; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
711 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
712 if (start < last && (*start == ' ' || *start == '"')) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
713 push = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
714 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
715 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
716 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
717 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
718 while (start < last && *start != ' ' && *start != '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
719 start++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
720 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
721 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
722 if (start == last) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
723 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
724 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
725 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
726 if (*start == '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
727 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
728 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
729 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
730 start++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
731 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
732 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
733 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
734 next_param: |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
735 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
736 start = ngx_strlchr(start, last, ';'); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
737 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
738 if (start == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
739 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
740 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
741 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
742 start++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
743 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
744 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
745 if (push) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
746 while (path.len && path.data[path.len - 1] == ' ') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
747 path.len--; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
748 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
749 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
750 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
751 if (push && path.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
752 && !(path.len > 1 && path.data[0] == '/' && path.data[1] == '/')) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
753 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
754 rc = ngx_http_v3_push_resource(r, &path, out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
755 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
756 if (rc == NGX_ERROR) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
757 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
758 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
759 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
760 if (rc == NGX_ABORT) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
761 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
762 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
763 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
764 /* NGX_OK, NGX_DECLINED */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
765 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
766 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
767 if (last < end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
768 start = last + 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
769 goto next_link; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
770 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
771 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
772 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
773 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
774 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
775 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
776 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
777 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
778 ngx_http_v3_push_resource(ngx_http_request_t *r, ngx_str_t *path, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
779 ngx_chain_t ***ll) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
780 { |
8430
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
781 uint64_t push_id; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
782 ngx_int_t rc; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
783 ngx_chain_t *cl; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
784 ngx_connection_t *c; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
785 ngx_http_v3_session_t *h3c; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
786 ngx_http_v3_srv_conf_t *h3scf; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
787 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
788 c = r->connection; |
8428
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8354
diff
changeset
|
789 h3c = ngx_http_v3_get_session(c); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
790 h3scf = ngx_http_get_module_srv_conf(r, ngx_http_v3_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
791 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
792 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, |
8354
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8350
diff
changeset
|
793 "http3 push \"%V\" pushing:%ui/%ui id:%uL/%L", |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
794 path, h3c->npushing, h3scf->max_concurrent_pushes, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
795 h3c->next_push_id, h3c->max_push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
796 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
797 if (!ngx_path_separator(path->data[0])) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
798 ngx_log_error(NGX_LOG_WARN, c->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
799 "non-absolute path \"%V\" not pushed", path); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
800 return NGX_DECLINED; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
801 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
802 |
8354
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8350
diff
changeset
|
803 if (h3c->max_push_id == (uint64_t) -1 |
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8350
diff
changeset
|
804 || h3c->next_push_id > h3c->max_push_id) |
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8350
diff
changeset
|
805 { |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
806 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
807 "http3 abort pushes due to max_push_id"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
808 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
809 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
810 |
8497
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
811 if (h3c->goaway_push_id != (uint64_t) -1) { |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
812 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
813 "http3 abort pushes due to goaway"); |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
814 return NGX_ABORT; |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
815 } |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8440
diff
changeset
|
816 |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
817 if (h3c->npushing >= h3scf->max_concurrent_pushes) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
818 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
819 "http3 abort pushes due to max_concurrent_pushes"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
820 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
821 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
822 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
823 push_id = h3c->next_push_id++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
824 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
825 rc = ngx_http_v3_create_push_request(r, path, push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
826 if (rc != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
827 return rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
828 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
829 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
830 cl = ngx_http_v3_create_push_promise(r, path, push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
831 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
832 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
833 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
834 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
835 for (**ll = cl; **ll; *ll = &(**ll)->next); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
836 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
837 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
838 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
839 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
840 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
841 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
842 ngx_http_v3_create_push_request(ngx_http_request_t *pr, ngx_str_t *path, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
843 uint64_t push_id) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
844 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
845 ngx_pool_t *pool; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
846 ngx_connection_t *c, *pc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
847 ngx_http_request_t *r; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
848 ngx_http_log_ctx_t *ctx; |
8440
557dc6a06ba6
HTTP/3: fixed server push after 9ec3e71f8a61.
Roman Arutyunyan <arut@nginx.com>
parents:
8430
diff
changeset
|
849 ngx_http_connection_t *hc, *phc; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
850 ngx_http_core_srv_conf_t *cscf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
851 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
852 pc = pr->connection; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
853 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
854 r = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
855 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
856 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
857 "http3 create push request id:%uL", push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
858 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
859 c = ngx_http_v3_create_push_stream(pc, push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
860 if (c == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
861 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
862 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
863 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
864 hc = ngx_palloc(c->pool, sizeof(ngx_http_connection_t)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
865 if (hc == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
866 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
867 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
868 |
8440
557dc6a06ba6
HTTP/3: fixed server push after 9ec3e71f8a61.
Roman Arutyunyan <arut@nginx.com>
parents:
8430
diff
changeset
|
869 phc = ngx_http_quic_get_connection(pc); |
557dc6a06ba6
HTTP/3: fixed server push after 9ec3e71f8a61.
Roman Arutyunyan <arut@nginx.com>
parents:
8430
diff
changeset
|
870 ngx_memcpy(hc, phc, sizeof(ngx_http_connection_t)); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
871 c->data = hc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
872 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
873 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
874 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
875 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
876 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
877 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
878 ctx->connection = c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
879 ctx->request = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
880 ctx->current_request = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
881 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
882 c->log->handler = ngx_http_log_error; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
883 c->log->data = ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
884 c->log->action = "processing pushed request headers"; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
885 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
886 c->log_error = NGX_ERROR_INFO; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
887 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
888 r = ngx_http_create_request(c); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
889 if (r == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
890 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
891 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
892 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
893 c->data = r; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
894 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
895 ngx_str_set(&r->http_protocol, "HTTP/3.0"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
896 |
8350
6bb924b00e30
HTTP/3: fixed server push.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8237
diff
changeset
|
897 r->http_version = NGX_HTTP_VERSION_30; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
898 r->method_name = ngx_http_core_get_method; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
899 r->method = NGX_HTTP_GET; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
900 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
901 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
902 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
903 r->header_in = ngx_create_temp_buf(r->pool, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
904 cscf->client_header_buffer_size); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
905 if (r->header_in == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
906 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
907 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
908 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
909 if (ngx_list_init(&r->headers_in.headers, r->pool, 4, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
910 sizeof(ngx_table_elt_t)) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
911 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
912 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
913 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
914 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
915 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
916 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
917 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
918 r->schema.data = ngx_pstrdup(r->pool, &pr->schema); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
919 if (r->schema.data == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
920 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
921 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
922 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
923 r->schema.len = pr->schema.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
924 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
925 r->uri_start = ngx_pstrdup(r->pool, path); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
926 if (r->uri_start == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
927 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
928 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
929 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
930 r->uri_end = r->uri_start + path->len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
931 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
932 if (ngx_http_parse_uri(r) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
933 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
934 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
935 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
936 if (ngx_http_process_request_uri(r) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
937 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
938 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
939 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
940 if (ngx_http_v3_set_push_header(r, "host", &pr->headers_in.server) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
941 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
942 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
943 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
944 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
945 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
946 if (pr->headers_in.accept_encoding) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
947 if (ngx_http_v3_set_push_header(r, "accept-encoding", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
948 &pr->headers_in.accept_encoding->value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
949 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
950 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
951 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
952 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
953 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
954 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
955 if (pr->headers_in.accept_language) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
956 if (ngx_http_v3_set_push_header(r, "accept-language", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
957 &pr->headers_in.accept_language->value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
958 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
959 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
960 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
961 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
962 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
963 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
964 if (pr->headers_in.user_agent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
965 if (ngx_http_v3_set_push_header(r, "user-agent", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
966 &pr->headers_in.user_agent->value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
967 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
968 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
969 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
970 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
971 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
972 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
973 c->read->handler = ngx_http_v3_push_request_handler; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
974 c->read->handler = ngx_http_v3_push_request_handler; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
975 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
976 ngx_post_event(c->read, &ngx_posted_events); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
977 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
978 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
979 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
980 failed: |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
981 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
982 if (r) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
983 ngx_http_free_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
984 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
985 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
986 c->destroyed = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
987 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
988 pool = c->pool; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
989 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
990 ngx_close_connection(c); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
991 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
992 ngx_destroy_pool(pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
993 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
994 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
995 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
996 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
997 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
998 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
999 ngx_http_v3_set_push_header(ngx_http_request_t *r, const char *name, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1000 ngx_str_t *value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1001 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1002 u_char *p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1003 ngx_table_elt_t *h; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1004 ngx_http_header_t *hh; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1005 ngx_http_core_main_conf_t *cmcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1006 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1007 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1008 "http3 push header \"%s\": \"%V\"", name, value); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1009 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1010 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1011 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1012 p = ngx_pnalloc(r->pool, value->len + 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1013 if (p == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1014 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1015 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1016 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1017 ngx_memcpy(p, value->data, value->len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1018 p[value->len] = '\0'; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1019 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1020 h = ngx_list_push(&r->headers_in.headers); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1021 if (h == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1022 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1023 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1024 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1025 h->key.data = (u_char *) name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1026 h->key.len = ngx_strlen(name); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1027 h->hash = ngx_hash_key(h->key.data, h->key.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1028 h->lowcase_key = (u_char *) name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1029 h->value.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1030 h->value.len = value->len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1031 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1032 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1033 h->lowcase_key, h->key.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1034 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1035 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1036 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1037 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1038 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1039 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1040 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1041 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1042 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1043 static void |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1044 ngx_http_v3_push_request_handler(ngx_event_t *ev) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1045 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1046 ngx_connection_t *c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1047 ngx_http_request_t *r; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1048 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1049 c = ev->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1050 r = c->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1051 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1052 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 push request handler"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1053 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1054 ngx_http_process_request(r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1055 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1056 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1057 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1058 static ngx_chain_t * |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1059 ngx_http_v3_create_push_promise(ngx_http_request_t *r, ngx_str_t *path, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1060 uint64_t push_id) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1061 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1062 size_t n, len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1063 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1064 ngx_chain_t *hl, *cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1065 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1066 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1067 "http3 create push promise id:%uL", push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1068 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1069 len = ngx_http_v3_encode_varlen_int(NULL, push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1070 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1071 len += ngx_http_v3_encode_field_section_prefix(NULL, 0, 0, 0); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1072 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1073 len += ngx_http_v3_encode_field_ri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1074 NGX_HTTP_V3_HEADER_METHOD_GET); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1075 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1076 len += ngx_http_v3_encode_field_lri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1077 NGX_HTTP_V3_HEADER_AUTHORITY, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1078 NULL, r->headers_in.server.len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1079 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1080 if (path->len == 1 && path->data[0] == '/') { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1081 len += ngx_http_v3_encode_field_ri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1082 NGX_HTTP_V3_HEADER_PATH_ROOT); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1083 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1084 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1085 len += ngx_http_v3_encode_field_lri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1086 NGX_HTTP_V3_HEADER_PATH_ROOT, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1087 NULL, path->len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1088 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1089 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1090 if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1091 len += ngx_http_v3_encode_field_ri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1092 NGX_HTTP_V3_HEADER_SCHEME_HTTPS); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1093 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1094 } else if (r->schema.len == 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1095 && ngx_strncmp(r->schema.data, "http", 4) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1096 { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1097 len += ngx_http_v3_encode_field_ri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1098 NGX_HTTP_V3_HEADER_SCHEME_HTTP); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1099 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1100 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1101 len += ngx_http_v3_encode_field_lri(NULL, 0, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1102 NGX_HTTP_V3_HEADER_SCHEME_HTTP, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1103 NULL, r->schema.len); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1104 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1105 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1106 if (r->headers_in.accept_encoding) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1107 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1108 NGX_HTTP_V3_HEADER_ACCEPT_ENCODING, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1109 r->headers_in.accept_encoding->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1110 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1111 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1112 if (r->headers_in.accept_language) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1113 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1114 NGX_HTTP_V3_HEADER_ACCEPT_LANGUAGE, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1115 r->headers_in.accept_language->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1116 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1117 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1118 if (r->headers_in.user_agent) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1119 len += ngx_http_v3_encode_field_lri(NULL, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1120 NGX_HTTP_V3_HEADER_USER_AGENT, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1121 r->headers_in.user_agent->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1122 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1123 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1124 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1125 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1126 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1127 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1128 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1129 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1130 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1131 b->last = (u_char *) ngx_http_v3_encode_field_section_prefix(b->last, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1132 0, 0, 0); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1133 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1134 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1135 NGX_HTTP_V3_HEADER_METHOD_GET); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1136 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1137 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1138 NGX_HTTP_V3_HEADER_AUTHORITY, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1139 r->headers_in.server.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1140 r->headers_in.server.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1141 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1142 if (path->len == 1 && path->data[0] == '/') { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1143 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1144 NGX_HTTP_V3_HEADER_PATH_ROOT); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1145 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1146 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1147 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1148 NGX_HTTP_V3_HEADER_PATH_ROOT, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1149 path->data, path->len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1150 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1151 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1152 if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1153 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1154 NGX_HTTP_V3_HEADER_SCHEME_HTTPS); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1155 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1156 } else if (r->schema.len == 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1157 && ngx_strncmp(r->schema.data, "http", 4) == 0) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1158 { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1159 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1160 NGX_HTTP_V3_HEADER_SCHEME_HTTP); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1161 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1162 } else { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1163 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1164 NGX_HTTP_V3_HEADER_SCHEME_HTTP, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1165 r->schema.data, r->schema.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1166 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1167 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1168 if (r->headers_in.accept_encoding) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1169 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1170 NGX_HTTP_V3_HEADER_ACCEPT_ENCODING, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1171 r->headers_in.accept_encoding->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1172 r->headers_in.accept_encoding->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1173 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1174 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1175 if (r->headers_in.accept_language) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1176 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1177 NGX_HTTP_V3_HEADER_ACCEPT_LANGUAGE, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1178 r->headers_in.accept_language->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1179 r->headers_in.accept_language->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1180 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1181 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1182 if (r->headers_in.user_agent) { |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8497
diff
changeset
|
1183 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1184 NGX_HTTP_V3_HEADER_USER_AGENT, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1185 r->headers_in.user_agent->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1186 r->headers_in.user_agent->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1187 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1188 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1189 cl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1190 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1191 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1192 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1193 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1194 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1195 cl->next = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1196 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1197 n = b->last - b->pos; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1198 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1199 len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_PUSH_PROMISE) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1200 + ngx_http_v3_encode_varlen_int(NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1201 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1202 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1203 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1204 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1205 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1206 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1207 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1208 NGX_HTTP_V3_FRAME_PUSH_PROMISE); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1209 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1210 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1211 hl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1212 if (hl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1213 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1214 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1215 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1216 hl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1217 hl->next = cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1218 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1219 return hl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1220 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1221 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1222 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1223 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1224 ngx_http_v3_body_filter(ngx_http_request_t *r, ngx_chain_t *in) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1225 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1226 u_char *chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1227 off_t size; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1228 ngx_int_t rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1229 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1230 ngx_chain_t *out, *cl, *tl, **ll; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1231 ngx_http_v3_filter_ctx_t *ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1232 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1233 if (in == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1234 return ngx_http_next_body_filter(r, in); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1235 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1236 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1237 ctx = ngx_http_get_module_ctx(r, ngx_http_v3_filter_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1238 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1239 return ngx_http_next_body_filter(r, in); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1240 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1241 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1242 out = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1243 ll = &out; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1244 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1245 size = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1246 cl = in; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1247 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1248 for ( ;; ) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1249 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1250 "http3 chunk: %O", ngx_buf_size(cl->buf)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1251 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1252 size += ngx_buf_size(cl->buf); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1253 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1254 if (cl->buf->flush |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1255 || cl->buf->sync |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1256 || ngx_buf_in_memory(cl->buf) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1257 || cl->buf->in_file) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1258 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1259 tl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1260 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1261 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1262 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1263 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1264 tl->buf = cl->buf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1265 *ll = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1266 ll = &tl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1267 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1268 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1269 if (cl->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1270 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1271 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1272 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1273 cl = cl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1274 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1275 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1276 if (size) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1277 tl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1278 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1279 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1280 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1281 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1282 b = tl->buf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1283 chunk = b->start; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1284 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1285 if (chunk == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1286 chunk = ngx_palloc(r->pool, NGX_HTTP_V3_VARLEN_INT_LEN * 2); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1287 if (chunk == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1288 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1289 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1290 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1291 b->start = chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1292 b->end = chunk + NGX_HTTP_V3_VARLEN_INT_LEN * 2; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1293 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1294 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1295 b->tag = (ngx_buf_tag_t) &ngx_http_v3_filter_module; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1296 b->memory = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1297 b->temporary = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1298 b->pos = chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1299 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1300 b->last = (u_char *) ngx_http_v3_encode_varlen_int(chunk, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1301 NGX_HTTP_V3_FRAME_DATA); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1302 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, size); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1303 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1304 tl->next = out; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1305 out = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1306 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1307 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1308 if (cl->buf->last_buf) { |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1309 tl = ngx_http_v3_create_trailers(r, ctx); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1310 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1311 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1312 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1313 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1314 cl->buf->last_buf = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1315 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1316 *ll = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1317 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1318 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1319 *ll = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1320 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1321 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1322 rc = ngx_http_next_body_filter(r, out); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1323 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1324 ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &out, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1325 (ngx_buf_tag_t) &ngx_http_v3_filter_module); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1326 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1327 return rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1328 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1329 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1330 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1331 static ngx_chain_t * |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1332 ngx_http_v3_create_trailers(ngx_http_request_t *r, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1333 ngx_http_v3_filter_ctx_t *ctx) |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1334 { |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1335 size_t len, n; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1336 u_char *p; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1337 ngx_buf_t *b; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1338 ngx_uint_t i; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1339 ngx_chain_t *cl, *hl; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1340 ngx_list_part_t *part; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1341 ngx_table_elt_t *header; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1342 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1343 len = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1344 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1345 part = &r->headers_out.trailers.part; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1346 header = part->elts; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1347 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1348 for (i = 0; /* void */; i++) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1349 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1350 if (i >= part->nelts) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1351 if (part->next == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1352 break; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1353 } |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1354 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1355 part = part->next; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1356 header = part->elts; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1357 i = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1358 } |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1359 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1360 if (header[i].hash == 0) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1361 continue; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1362 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1363 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1364 len += ngx_http_v3_encode_field_l(NULL, &header[i].key, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1365 &header[i].value); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1366 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1367 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1368 cl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1369 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1370 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1371 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1372 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1373 b = cl->buf; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1374 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1375 b->tag = (ngx_buf_tag_t) &ngx_http_v3_filter_module; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1376 b->memory = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1377 b->last_buf = 1; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1378 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1379 if (len == 0) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1380 b->temporary = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1381 b->pos = b->last = NULL; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1382 return cl; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1383 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1384 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1385 b->temporary = 1; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1386 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1387 len += ngx_http_v3_encode_field_section_prefix(NULL, 0, 0, 0); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1388 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1389 b->pos = ngx_palloc(r->pool, len); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1390 if (b->pos == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1391 return NULL; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1392 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1393 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1394 b->last = (u_char *) ngx_http_v3_encode_field_section_prefix(b->pos, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1395 0, 0, 0); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1396 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1397 part = &r->headers_out.trailers.part; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1398 header = part->elts; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1399 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1400 for (i = 0; /* void */; i++) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1401 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1402 if (i >= part->nelts) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1403 if (part->next == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1404 break; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1405 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1406 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1407 part = part->next; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1408 header = part->elts; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1409 i = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1410 } |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1411 |
8542
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1412 if (header[i].hash == 0) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1413 continue; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1414 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1415 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1416 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1417 "http3 trailer: \"%V: %V\"", |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1418 &header[i].key, &header[i].value); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1419 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1420 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1421 &header[i].key, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1422 &header[i].value); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1423 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1424 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1425 n = b->last - b->pos; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1426 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1427 hl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1428 if (hl == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1429 return NULL; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1430 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1431 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1432 b = hl->buf; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1433 p = b->start; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1434 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1435 if (p == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1436 p = ngx_palloc(r->pool, NGX_HTTP_V3_VARLEN_INT_LEN * 2); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1437 if (p == NULL) { |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1438 return NULL; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1439 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1440 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1441 b->start = p; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1442 b->end = p + NGX_HTTP_V3_VARLEN_INT_LEN * 2; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1443 } |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1444 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1445 b->tag = (ngx_buf_tag_t) &ngx_http_v3_filter_module; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1446 b->memory = 0; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1447 b->temporary = 1; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1448 b->pos = p; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1449 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1450 b->last = (u_char *) ngx_http_v3_encode_varlen_int(p, |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1451 NGX_HTTP_V3_FRAME_HEADERS); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1452 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1453 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1454 hl->next = cl; |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1455 |
8e8cdb7bfb17
HTTP/3: response trailers support.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
1456 return hl; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1457 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1458 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1459 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1460 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1461 ngx_http_v3_filter_init(ngx_conf_t *cf) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1462 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1463 ngx_http_next_header_filter = ngx_http_top_header_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1464 ngx_http_top_header_filter = ngx_http_v3_header_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1465 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1466 ngx_http_next_body_filter = ngx_http_top_body_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1467 ngx_http_top_body_filter = ngx_http_v3_body_filter; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1468 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1469 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1470 } |