Mercurial > hg > nginx-quic
annotate src/http/v3/ngx_http_v3_filter_module.c @ 8379:0f8565e0fc76 quic
QUIC: HKDF API compatibility with OpenSSL master branch.
OpenSSL 3.0 started to require HKDF-Extract output PRK length pointer
used to represent the amount of data written to contain the length of
the key buffer before the call. EVP_PKEY_derive() documents this.
See HKDF_Extract() internal implementation update in this change:
https://github.com/openssl/openssl/commit/5a285ad
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 31 Mar 2021 21:43:17 +0300 |
parents | 5cb5b568282b |
children | 40d710a66aef |
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); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
52 static ngx_chain_t *ngx_http_v3_create_trailers(ngx_http_request_t *r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
53 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
|
54 |
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 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
|
57 NULL, /* preconfiguration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
58 ngx_http_v3_filter_init, /* postconfiguration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
59 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
60 NULL, /* create main configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
61 NULL, /* init main configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
62 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
63 NULL, /* create server configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
64 NULL, /* merge server configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
65 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
66 NULL, /* create location configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
67 NULL /* merge location configuration */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
68 }; |
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 ngx_module_t ngx_http_v3_filter_module = { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
72 NGX_MODULE_V1, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
73 &ngx_http_v3_filter_module_ctx, /* module context */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
74 NULL, /* module directives */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
75 NGX_HTTP_MODULE, /* module type */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
76 NULL, /* init master */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
77 NULL, /* init module */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
78 NULL, /* init process */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
79 NULL, /* init thread */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
80 NULL, /* exit thread */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
81 NULL, /* exit process */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
82 NULL, /* exit master */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
83 NGX_MODULE_V1_PADDING |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
84 }; |
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 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
|
88 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
|
89 |
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 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
92 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
|
93 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
94 u_char *p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
95 size_t len, n; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
96 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
97 ngx_str_t host; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
98 ngx_uint_t i, port; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
99 ngx_chain_t *out, *hl, *cl, **ll; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
100 ngx_list_part_t *part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
101 ngx_table_elt_t *header; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
102 ngx_connection_t *c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
103 ngx_http_v3_filter_ctx_t *ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
104 ngx_http_core_loc_conf_t *clcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
105 ngx_http_core_srv_conf_t *cscf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
106 u_char addr[NGX_SOCKADDR_STRLEN]; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
107 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
108 if (r->http_version != NGX_HTTP_VERSION_30) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
109 return ngx_http_next_header_filter(r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
110 } |
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 if (r->header_sent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
113 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
114 } |
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 r->header_sent = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
117 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
118 if (r != r->main) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
119 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
120 } |
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 if (r->method == NGX_HTTP_HEAD) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
123 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
124 } |
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 if (r->headers_out.last_modified_time != -1) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
127 if (r->headers_out.status != NGX_HTTP_OK |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
128 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
129 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
130 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
131 r->headers_out.last_modified_time = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
132 r->headers_out.last_modified = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
133 } |
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 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
|
137 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
138 ngx_str_null(&r->headers_out.content_type); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
139 r->headers_out.last_modified_time = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
140 r->headers_out.last_modified = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
141 r->headers_out.content_length = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
142 r->headers_out.content_length_n = -1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
143 } |
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 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
|
146 r->header_only = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
147 } |
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 c = r->connection; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
150 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
151 out = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
152 ll = &out; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
153 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
154 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
|
155 && r->method != NGX_HTTP_HEAD) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
156 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
157 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
|
158 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
159 } |
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 len = ngx_http_v3_encode_header_block_prefix(NULL, 0, 0, 0); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
163 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
164 if (r->headers_out.status == NGX_HTTP_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
165 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
166 NGX_HTTP_V3_HEADER_STATUS_200); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
167 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
168 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
169 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
170 NGX_HTTP_V3_HEADER_STATUS_200, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
171 NULL, 3); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
172 } |
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 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
|
175 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
176 if (r->headers_out.server == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
177 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
|
178 n = sizeof(NGINX_VER) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
179 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
180 } 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
|
181 n = sizeof(NGINX_VER_BUILD) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
182 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
183 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
184 n = sizeof("nginx") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
185 } |
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 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
188 NGX_HTTP_V3_HEADER_SERVER, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
189 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
190 } |
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 if (r->headers_out.date == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
193 len += ngx_http_v3_encode_header_lri(NULL, 0, NGX_HTTP_V3_HEADER_DATE, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
194 NULL, ngx_cached_http_time.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
195 } |
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 if (r->headers_out.content_type.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
198 n = r->headers_out.content_type.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
199 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
200 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
|
201 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
202 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
203 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
|
204 } |
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 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
207 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
208 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
209 } |
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 if (r->headers_out.content_length == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
212 if (r->headers_out.content_length_n > 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
213 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
214 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
215 NULL, NGX_OFF_T_LEN); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
216 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
217 } else if (r->headers_out.content_length_n == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
218 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
219 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
220 } |
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 if (r->headers_out.last_modified == NULL |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
224 && r->headers_out.last_modified_time != -1) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
225 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
226 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
227 NGX_HTTP_V3_HEADER_LAST_MODIFIED, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
228 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
|
229 } |
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 if (r->headers_out.location |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
232 && r->headers_out.location->value.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
233 && r->headers_out.location->value.data[0] == '/' |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
234 && clcf->absolute_redirect) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
235 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
236 r->headers_out.location->hash = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
237 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
238 if (clcf->server_name_in_redirect) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
239 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
|
240 host = cscf->server_name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
241 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
242 } else if (r->headers_in.server.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
243 host = r->headers_in.server; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
244 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
245 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
246 host.len = NGX_SOCKADDR_STRLEN; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
247 host.data = addr; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
248 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
249 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
|
250 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
251 } |
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 port = ngx_inet_get_port(c->local_sockaddr); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
255 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
256 n = sizeof("https://") - 1 + host.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
257 + r->headers_out.location->value.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
258 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
259 if (clcf->port_in_redirect) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
260 port = (port == 443) ? 0 : port; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
261 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
262 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
263 port = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
264 } |
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 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
267 n += sizeof(":65535") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
268 } |
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 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
271 NGX_HTTP_V3_HEADER_LOCATION, NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
272 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
273 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
274 ngx_str_null(&host); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
275 port = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
276 } |
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 #if (NGX_HTTP_GZIP) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
279 if (r->gzip_vary) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
280 if (clcf->gzip_vary) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
281 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
282 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
283 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
284 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
285 r->gzip_vary = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
286 } |
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 #endif |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
289 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
290 part = &r->headers_out.headers.part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
291 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
292 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
293 for (i = 0; /* void */; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
294 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
295 if (i >= part->nelts) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
296 if (part->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
297 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
298 } |
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 part = part->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
301 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
302 i = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
303 } |
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 if (header[i].hash == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
306 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
307 } |
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 len += ngx_http_v3_encode_header_l(NULL, &header[i].key, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
310 &header[i].value); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
311 } |
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 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
|
314 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
315 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
316 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
317 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
318 } |
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 b->last = (u_char *) ngx_http_v3_encode_header_block_prefix(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
321 0, 0, 0); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
322 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
323 if (r->headers_out.status == NGX_HTTP_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
324 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
325 NGX_HTTP_V3_HEADER_STATUS_200); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
326 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
327 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
328 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
329 NGX_HTTP_V3_HEADER_STATUS_200, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
330 NULL, 3); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
331 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
|
332 } |
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 if (r->headers_out.server == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
335 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
|
336 p = (u_char *) NGINX_VER; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
337 n = sizeof(NGINX_VER) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
338 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
339 } 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
|
340 p = (u_char *) NGINX_VER_BUILD; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
341 n = sizeof(NGINX_VER_BUILD) - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
342 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
343 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
344 p = (u_char *) "nginx"; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
345 n = sizeof("nginx") - 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
346 } |
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 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
349 NGX_HTTP_V3_HEADER_SERVER, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
350 p, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
351 } |
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 if (r->headers_out.date == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
354 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
355 NGX_HTTP_V3_HEADER_DATE, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
356 ngx_cached_http_time.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
357 ngx_cached_http_time.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
358 } |
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 if (r->headers_out.content_type.len) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
361 n = r->headers_out.content_type.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
362 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
363 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
|
364 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
365 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
366 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
|
367 } |
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 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
370 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
371 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
372 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
373 p = b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
374 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
|
375 r->headers_out.content_type.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
376 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
377 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
|
378 && r->headers_out.charset.len) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
379 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
380 b->last = ngx_cpymem(b->last, "; charset=", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
381 sizeof("; charset=") - 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
382 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
|
383 r->headers_out.charset.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
384 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
385 /* 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
|
386 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
387 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
|
388 r->headers_out.content_type.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
389 } |
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 if (r->headers_out.content_length == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
393 if (r->headers_out.content_length_n > 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
394 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
|
395 n = p - b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
396 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
397 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
398 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
399 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
400 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
401 b->last = ngx_sprintf(b->last, "%O", |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
402 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
403 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
404 } else if (r->headers_out.content_length_n == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
405 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
406 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
407 } |
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 if (r->headers_out.last_modified == NULL |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
411 && r->headers_out.last_modified_time != -1) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
412 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
413 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
414 NGX_HTTP_V3_HEADER_LAST_MODIFIED, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
415 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
|
416 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
417 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
|
418 } |
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 if (host.data) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
421 n = sizeof("https://") - 1 + host.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
422 + r->headers_out.location->value.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
423 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
424 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
425 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
|
426 } |
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 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
429 NGX_HTTP_V3_HEADER_LOCATION, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
430 NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
431 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
432 p = b->last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
433 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
|
434 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
|
435 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
436 if (port) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
437 b->last = ngx_sprintf(b->last, ":%ui", port); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
438 } |
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 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
|
441 r->headers_out.location->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
442 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
443 /* 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
|
444 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
445 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
|
446 r->headers_out.location->value.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
447 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
|
448 } |
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 #if (NGX_HTTP_GZIP) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
451 if (r->gzip_vary) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
452 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
453 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
454 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
455 #endif |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
456 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
457 part = &r->headers_out.headers.part; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
458 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
459 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
460 for (i = 0; /* void */; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
461 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
462 if (i >= part->nelts) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
463 if (part->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
464 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
465 } |
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 part = part->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
468 header = part->elts; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
469 i = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
470 } |
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 if (header[i].hash == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
473 continue; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
474 } |
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 b->last = (u_char *) ngx_http_v3_encode_header_l(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
477 &header[i].key, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
478 &header[i].value); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
479 } |
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 if (r->header_only) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
482 b->last_buf = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
483 } |
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 cl = ngx_alloc_chain_link(c->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
486 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
487 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
488 } |
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 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
491 cl->next = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
492 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
493 n = b->last - b->pos; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
494 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
495 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
|
496 + ngx_http_v3_encode_varlen_int(NULL, n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
497 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
498 b = ngx_create_temp_buf(c->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
499 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
500 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
501 } |
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 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
|
504 NGX_HTTP_V3_FRAME_HEADERS); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
505 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
|
506 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
507 hl = ngx_alloc_chain_link(c->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
508 if (hl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
509 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
510 } |
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 hl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
513 hl->next = cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
514 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
515 *ll = hl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
516 ll = &cl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
517 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
518 if (r->headers_out.content_length_n >= 0 && !r->header_only) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
519 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
|
520 + ngx_http_v3_encode_varlen_int(NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
521 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
522 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
523 b = ngx_create_temp_buf(c->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
524 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
525 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
526 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
527 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
528 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
|
529 NGX_HTTP_V3_FRAME_DATA); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
530 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
|
531 r->headers_out.content_length_n); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
532 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
533 cl = ngx_alloc_chain_link(c->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
534 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
535 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
536 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
537 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
538 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
539 cl->next = NULL; |
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 *ll = cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
542 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
543 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
544 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
|
545 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
546 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
547 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
548 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
549 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
|
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 return ngx_http_write_filter(r, out); |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
556 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
557 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
|
558 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
559 u_char *start, *end, *last; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
560 ngx_str_t path; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
561 ngx_int_t rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
562 ngx_uint_t i, push; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
563 ngx_table_elt_t **h; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
564 ngx_http_v3_loc_conf_t *h3lcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
565 ngx_http_complex_value_t *pushes; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
566 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
567 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
|
568 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
569 if (h3lcf->pushes) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
570 pushes = h3lcf->pushes->elts; |
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 for (i = 0; i < h3lcf->pushes->nelts; i++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
573 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
574 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
|
575 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
578 if (path.len == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
579 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
582 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
|
583 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
586 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
|
587 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
588 if (rc == NGX_ERROR) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
589 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
592 if (rc == NGX_ABORT) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
593 return NGX_OK; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
596 /* NGX_OK, NGX_DECLINED */ |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
600 if (!h3lcf->push_preload) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
601 return NGX_OK; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
604 h = r->headers_out.link.elts; |
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 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
|
607 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
608 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
|
609 "http3 parse link: \"%V\"", &h[i]->value); |
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 start = h[i]->value.data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
612 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
|
613 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
614 next_link: |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
615 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
616 while (start < end && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
617 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
618 if (start == end || *start++ != '<') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
619 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
622 while (start < end && *start == ' ') { start++; } |
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 for (last = start; last < end && *last != '>'; last++) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
625 /* void */ |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
628 if (last == start || last == end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
629 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
632 path.len = last - start; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
633 path.data = start; |
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 start = last + 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
636 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
637 while (start < end && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
638 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
639 if (start == end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
640 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
643 if (*start == ',') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
644 start++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
645 goto next_link; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
646 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
647 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
648 if (*start++ != ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
649 continue; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
652 last = ngx_strlchr(start, end, ','); |
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 if (last == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
655 last = 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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
658 push = 0; |
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 for ( ;; ) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
661 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
662 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
663 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
664 if (last - start >= 6 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
665 && ngx_strncasecmp(start, (u_char *) "nopush", 6) == 0) |
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 start += 6; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
668 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
669 if (start == last || *start == ' ' || *start == ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
670 push = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
671 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
672 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
673 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
674 goto next_param; |
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 if (last - start >= 11 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
678 && 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
|
679 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
680 start += 11; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
681 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
682 if (start == last || *start == ' ' || *start == ';') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
683 push = 1; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
686 goto next_param; |
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 if (last - start >= 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
690 && ngx_strncasecmp(start, (u_char *) "rel=", 4) == 0) |
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 start += 4; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
693 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
694 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
695 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
696 if (start == last || *start++ != '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
697 goto next_param; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
700 for ( ;; ) { |
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 while (start < last && *start == ' ') { start++; } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
703 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
704 if (last - start >= 7 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
705 && ngx_strncasecmp(start, (u_char *) "preload", 7) == 0) |
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 start += 7; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
708 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
709 if (start < last && (*start == ' ' || *start == '"')) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
710 push = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
711 break; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
712 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
713 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
714 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
715 while (start < last && *start != ' ' && *start != '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
716 start++; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
719 if (start == last) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
720 break; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
723 if (*start == '"') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
724 break; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
727 start++; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
731 next_param: |
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 start = ngx_strlchr(start, last, ';'); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
734 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
735 if (start == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
736 break; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
739 start++; |
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 if (push) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
743 while (path.len && path.data[path.len - 1] == ' ') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
744 path.len--; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
745 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
746 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
747 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
748 if (push && path.len |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
749 && !(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
|
750 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
751 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
|
752 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
753 if (rc == NGX_ERROR) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
754 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
757 if (rc == NGX_ABORT) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
758 return NGX_OK; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
761 /* NGX_OK, NGX_DECLINED */ |
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 if (last < end) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
765 start = last + 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
766 goto next_link; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
767 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
768 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
769 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
770 return NGX_OK; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
774 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
775 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
|
776 ngx_chain_t ***ll) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
777 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
778 uint64_t push_id; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
779 ngx_int_t rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
780 ngx_chain_t *cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
781 ngx_connection_t *c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
782 ngx_http_v3_srv_conf_t *h3scf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
783 ngx_http_v3_connection_t *h3c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
784 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
785 c = r->connection; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
786 h3c = c->quic->parent->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
787 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
|
788 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
789 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
|
790 "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
|
791 path, h3c->npushing, h3scf->max_concurrent_pushes, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
792 h3c->next_push_id, h3c->max_push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
793 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
794 if (!ngx_path_separator(path->data[0])) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
795 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
|
796 "non-absolute path \"%V\" not pushed", path); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
797 return NGX_DECLINED; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
798 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
799 |
8354
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8350
diff
changeset
|
800 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
|
801 || 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
|
802 { |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
803 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
|
804 "http3 abort pushes due to max_push_id"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
805 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
806 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
807 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
808 if (h3c->npushing >= h3scf->max_concurrent_pushes) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
809 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
|
810 "http3 abort pushes due to max_concurrent_pushes"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
811 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
812 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
813 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
814 push_id = h3c->next_push_id++; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
815 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
816 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
|
817 if (rc != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
818 return rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
819 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
820 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
821 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
|
822 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
823 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
826 for (**ll = cl; **ll; *ll = &(**ll)->next); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
827 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
828 return NGX_OK; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
831 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
832 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
833 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
|
834 uint64_t push_id) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
835 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
836 ngx_pool_t *pool; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
837 ngx_connection_t *c, *pc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
838 ngx_http_request_t *r; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
839 ngx_http_log_ctx_t *ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
840 ngx_http_connection_t *hc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
841 ngx_http_core_srv_conf_t *cscf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
842 ngx_http_v3_connection_t *h3c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
843 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
844 pc = pr->connection; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
845 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
846 r = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
847 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
848 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
|
849 "http3 create push request id:%uL", push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
850 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
851 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
|
852 if (c == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
853 return NGX_ABORT; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
854 } |
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 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
|
857 if (hc == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
858 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
859 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
860 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
861 h3c = c->quic->parent->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
862 ngx_memcpy(hc, h3c, sizeof(ngx_http_connection_t)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
863 c->data = hc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
864 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
865 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
|
866 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
867 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
868 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
869 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
870 ctx->connection = c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
871 ctx->request = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
872 ctx->current_request = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
873 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
874 c->log->handler = ngx_http_log_error; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
875 c->log->data = ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
876 c->log->action = "processing pushed request headers"; |
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 c->log_error = NGX_ERROR_INFO; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
879 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
880 r = ngx_http_create_request(c); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
881 if (r == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
882 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
883 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
884 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
885 c->data = r; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
886 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
887 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
|
888 |
8350
6bb924b00e30
HTTP/3: fixed server push.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8237
diff
changeset
|
889 r->http_version = NGX_HTTP_VERSION_30; |
8237
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
890 r->method_name = ngx_http_core_get_method; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
891 r->method = NGX_HTTP_GET; |
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 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
|
894 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
895 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
|
896 cscf->client_header_buffer_size); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
897 if (r->header_in == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
898 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
899 } |
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 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
|
902 sizeof(ngx_table_elt_t)) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
903 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
904 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
905 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
906 } |
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 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
|
909 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
910 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
|
911 if (r->schema.data == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
912 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
913 } |
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 r->schema.len = pr->schema.len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
916 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
917 r->uri_start = ngx_pstrdup(r->pool, path); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
918 if (r->uri_start == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
919 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
920 } |
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 r->uri_end = r->uri_start + path->len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
923 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
924 if (ngx_http_parse_uri(r) != NGX_OK) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
925 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
926 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
927 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
928 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
|
929 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
930 } |
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_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
|
933 != NGX_OK) |
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 goto failed; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
936 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
937 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
938 if (pr->headers_in.accept_encoding) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
939 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
|
940 &pr->headers_in.accept_encoding->value) |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
947 if (pr->headers_in.accept_language) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
948 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
|
949 &pr->headers_in.accept_language->value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
950 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
951 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
952 goto failed; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
956 if (pr->headers_in.user_agent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
957 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
|
958 &pr->headers_in.user_agent->value) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
959 != NGX_OK) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
960 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
961 goto failed; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
965 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
|
966 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
|
967 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
968 ngx_post_event(c->read, &ngx_posted_events); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
969 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
970 return NGX_OK; |
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 failed: |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
973 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
974 if (r) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
975 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
|
976 } |
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 c->destroyed = 1; |
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 pool = c->pool; |
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 ngx_close_connection(c); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
983 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
984 ngx_destroy_pool(pool); |
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 return NGX_ERROR; |
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 |
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 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
991 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
|
992 ngx_str_t *value) |
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 u_char *p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
995 ngx_table_elt_t *h; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
996 ngx_http_header_t *hh; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
997 ngx_http_core_main_conf_t *cmcf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
998 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
999 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
|
1000 "http3 push header \"%s\": \"%V\"", name, 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 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
|
1003 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1004 p = ngx_pnalloc(r->pool, value->len + 1); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1005 if (p == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1006 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1007 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1008 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1009 ngx_memcpy(p, value->data, value->len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1010 p[value->len] = '\0'; |
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 h = ngx_list_push(&r->headers_in.headers); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1013 if (h == 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 h->key.data = (u_char *) name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1018 h->key.len = ngx_strlen(name); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1019 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
|
1020 h->lowcase_key = (u_char *) name; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1021 h->value.data = p; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1022 h->value.len = value->len; |
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 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
|
1025 h->lowcase_key, h->key.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1026 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1027 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
|
1028 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1029 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1030 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1031 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1032 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1033 |
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 static void |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1036 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
|
1037 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1038 ngx_connection_t *c; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1039 ngx_http_request_t *r; |
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 c = ev->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1042 r = c->data; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1043 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1044 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
|
1045 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1046 ngx_http_process_request(r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1047 } |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1050 static ngx_chain_t * |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1051 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
|
1052 uint64_t push_id) |
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 size_t n, len; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1055 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1056 ngx_chain_t *hl, *cl; |
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 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
|
1059 "http3 create push promise id:%uL", push_id); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1060 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1061 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
|
1062 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1063 len += ngx_http_v3_encode_header_block_prefix(NULL, 0, 0, 0); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1064 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1065 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1066 NGX_HTTP_V3_HEADER_METHOD_GET); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1067 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1068 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1069 NGX_HTTP_V3_HEADER_AUTHORITY, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1070 NULL, r->headers_in.server.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1071 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1072 if (path->len == 1 && path->data[0] == '/') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1073 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1074 NGX_HTTP_V3_HEADER_PATH_ROOT); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1075 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1076 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1077 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1078 NGX_HTTP_V3_HEADER_PATH_ROOT, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1079 NULL, path->len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1080 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1081 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1082 if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1083 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1084 NGX_HTTP_V3_HEADER_SCHEME_HTTPS); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1085 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1086 } else if (r->schema.len == 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1087 && ngx_strncmp(r->schema.data, "http", 4) == 0) |
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 len += ngx_http_v3_encode_header_ri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1090 NGX_HTTP_V3_HEADER_SCHEME_HTTP); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1091 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1092 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1093 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1094 NGX_HTTP_V3_HEADER_SCHEME_HTTP, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1095 NULL, r->schema.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1096 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1097 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1098 if (r->headers_in.accept_encoding) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1099 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1100 NGX_HTTP_V3_HEADER_ACCEPT_ENCODING, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1101 r->headers_in.accept_encoding->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1102 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1103 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1104 if (r->headers_in.accept_language) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1105 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1106 NGX_HTTP_V3_HEADER_ACCEPT_LANGUAGE, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1107 r->headers_in.accept_language->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1108 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1109 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1110 if (r->headers_in.user_agent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1111 len += ngx_http_v3_encode_header_lri(NULL, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1112 NGX_HTTP_V3_HEADER_USER_AGENT, NULL, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1113 r->headers_in.user_agent->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1114 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1115 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1116 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1117 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1118 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1119 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1120 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1121 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
|
1122 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1123 b->last = (u_char *) ngx_http_v3_encode_header_block_prefix(b->last, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1124 0, 0, 0); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1125 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1126 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1127 NGX_HTTP_V3_HEADER_METHOD_GET); |
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_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1130 NGX_HTTP_V3_HEADER_AUTHORITY, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1131 r->headers_in.server.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1132 r->headers_in.server.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1133 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1134 if (path->len == 1 && path->data[0] == '/') { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1135 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1136 NGX_HTTP_V3_HEADER_PATH_ROOT); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1137 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1138 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1139 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1140 NGX_HTTP_V3_HEADER_PATH_ROOT, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1141 path->data, path->len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1142 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1143 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1144 if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1145 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1146 NGX_HTTP_V3_HEADER_SCHEME_HTTPS); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1147 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1148 } else if (r->schema.len == 4 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1149 && ngx_strncmp(r->schema.data, "http", 4) == 0) |
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 b->last = (u_char *) ngx_http_v3_encode_header_ri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1152 NGX_HTTP_V3_HEADER_SCHEME_HTTP); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1153 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1154 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1155 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1156 NGX_HTTP_V3_HEADER_SCHEME_HTTP, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1157 r->schema.data, r->schema.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1158 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1159 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1160 if (r->headers_in.accept_encoding) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1161 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1162 NGX_HTTP_V3_HEADER_ACCEPT_ENCODING, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1163 r->headers_in.accept_encoding->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1164 r->headers_in.accept_encoding->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1165 } |
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 if (r->headers_in.accept_language) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1168 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1169 NGX_HTTP_V3_HEADER_ACCEPT_LANGUAGE, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1170 r->headers_in.accept_language->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1171 r->headers_in.accept_language->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1172 } |
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 if (r->headers_in.user_agent) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1175 b->last = (u_char *) ngx_http_v3_encode_header_lri(b->last, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1176 NGX_HTTP_V3_HEADER_USER_AGENT, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1177 r->headers_in.user_agent->value.data, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1178 r->headers_in.user_agent->value.len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1179 } |
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 cl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1182 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1183 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1184 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1185 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1186 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1187 cl->next = NULL; |
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 n = b->last - b->pos; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1190 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1191 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
|
1192 + ngx_http_v3_encode_varlen_int(NULL, n); |
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 b = ngx_create_temp_buf(r->pool, len); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1195 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1196 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1197 } |
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 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
|
1200 NGX_HTTP_V3_FRAME_PUSH_PROMISE); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1201 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
|
1202 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1203 hl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1204 if (hl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1205 return NULL; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1208 hl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1209 hl->next = cl; |
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 return hl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1212 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1213 |
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 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1216 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
|
1217 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1218 u_char *chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1219 off_t size; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1220 ngx_int_t rc; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1221 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1222 ngx_chain_t *out, *cl, *tl, **ll; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1223 ngx_http_v3_filter_ctx_t *ctx; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1224 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1225 if (in == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1226 return ngx_http_next_body_filter(r, in); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1227 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1228 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1229 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
|
1230 if (ctx == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1231 return ngx_http_next_body_filter(r, in); |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1234 out = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1235 ll = &out; |
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 size = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1238 cl = in; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1239 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1240 for ( ;; ) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1241 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
|
1242 "http3 chunk: %O", ngx_buf_size(cl->buf)); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1243 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1244 size += ngx_buf_size(cl->buf); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1245 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1246 if (cl->buf->flush |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1247 || cl->buf->sync |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1248 || ngx_buf_in_memory(cl->buf) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1249 || cl->buf->in_file) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1250 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1251 tl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1252 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1253 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1254 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1255 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1256 tl->buf = cl->buf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1257 *ll = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1258 ll = &tl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1259 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1260 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1261 if (cl->next == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1262 break; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1265 cl = cl->next; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1266 } |
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 if (size) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1269 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
|
1270 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1271 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1274 b = tl->buf; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1275 chunk = b->start; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1276 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1277 if (chunk == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1278 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
|
1279 if (chunk == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1280 return NGX_ERROR; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1283 b->start = chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1284 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
|
1285 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1286 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1287 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
|
1288 b->memory = 0; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1289 b->temporary = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1290 b->pos = chunk; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1291 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1292 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
|
1293 NGX_HTTP_V3_FRAME_DATA); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1294 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
|
1295 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1296 tl->next = out; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1297 out = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1298 } |
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 if (cl->buf->last_buf) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1301 tl = ngx_http_v3_create_trailers(r); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1302 if (tl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1303 return NGX_ERROR; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1304 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1305 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1306 cl->buf->last_buf = 0; |
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 *ll = tl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1309 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1310 } else { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1311 *ll = NULL; |
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 rc = ngx_http_next_body_filter(r, out); |
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 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
|
1317 (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
|
1318 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1319 return rc; |
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 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1323 static ngx_chain_t * |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1324 ngx_http_v3_create_trailers(ngx_http_request_t *r) |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1325 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1326 ngx_buf_t *b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1327 ngx_chain_t *cl; |
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 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1330 "http3 create trailers"); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1331 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1332 /* XXX */ |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1333 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1334 b = ngx_calloc_buf(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1335 if (b == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1336 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1337 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1338 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1339 b->last_buf = 1; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1340 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1341 cl = ngx_alloc_chain_link(r->pool); |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1342 if (cl == NULL) { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1343 return NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1344 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1345 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1346 cl->buf = b; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1347 cl->next = NULL; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1348 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1349 return cl; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1350 } |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1351 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1352 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1353 static ngx_int_t |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1354 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
|
1355 { |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1356 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
|
1357 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
|
1358 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1359 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
|
1360 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
|
1361 |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1362 return NGX_OK; |
1efee5e4194c
HTTP/3: introduced ngx_http_v3_filter.
Roman Arutyunyan <arut@nginx.com>
parents:
diff
changeset
|
1363 } |