Mercurial > hg > nginx-quic
annotate src/http/v3/ngx_http_v3_module.c @ 8352:0a0b1de9ccab quic
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
A reasonable codepoint is always set[1] explicitly so that it doesn't
depend on the default library value that may change[2] in the future.
[1] https://boringssl.googlesource.com/boringssl/+/3d8b8c3d
[2] https://boringssl.googlesource.com/boringssl/+/c47bfce0
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 16 Mar 2021 13:48:28 +0300 |
parents | ae2e68f206f9 |
children | f0882db8c8d4 |
rev | line source |
---|---|
7681 | 1 |
2 /* | |
3 * Copyright (C) Nginx, Inc. | |
4 * Copyright (C) Roman Arutyunyan | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
8011
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
13 static ngx_int_t ngx_http_variable_http3(ngx_http_request_t *r, |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
14 ngx_http_variable_value_t *v, uintptr_t data); |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
15 static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf); |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
16 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
17 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
18 void *child); |
8015 | 19 static void *ngx_http_v3_create_loc_conf(ngx_conf_t *cf); |
20 static char *ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent, | |
21 void *child); | |
22 static char *ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
8011
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
23 |
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
24 |
7681 | 25 static ngx_command_t ngx_http_v3_commands[] = { |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
26 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
27 { ngx_string("http3_max_table_capacity"), |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
28 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
29 ngx_conf_set_size_slot, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
30 NGX_HTTP_SRV_CONF_OFFSET, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
31 offsetof(ngx_http_v3_srv_conf_t, max_table_capacity), |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
32 NULL }, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
33 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
34 { ngx_string("http3_max_blocked_streams"), |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
35 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
36 ngx_conf_set_num_slot, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
37 NGX_HTTP_SRV_CONF_OFFSET, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
38 offsetof(ngx_http_v3_srv_conf_t, max_blocked_streams), |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
39 NULL }, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
40 |
8015 | 41 { ngx_string("http3_max_concurrent_pushes"), |
42 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
43 ngx_conf_set_num_slot, | |
44 NGX_HTTP_SRV_CONF_OFFSET, | |
45 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_pushes), | |
46 NULL }, | |
47 | |
48 { ngx_string("http3_push"), | |
49 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
50 ngx_http_v3_push, | |
51 NGX_HTTP_LOC_CONF_OFFSET, | |
52 0, | |
53 NULL }, | |
54 | |
55 { ngx_string("http3_push_preload"), | |
56 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
57 ngx_conf_set_flag_slot, | |
58 NGX_HTTP_LOC_CONF_OFFSET, | |
59 offsetof(ngx_http_v3_loc_conf_t, push_preload), | |
60 NULL }, | |
61 | |
7681 | 62 ngx_null_command |
63 }; | |
64 | |
65 | |
66 static ngx_http_module_t ngx_http_v3_module_ctx = { | |
7714
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
67 ngx_http_v3_add_variables, /* preconfiguration */ |
7681 | 68 NULL, /* postconfiguration */ |
69 | |
70 NULL, /* create main configuration */ | |
71 NULL, /* init main configuration */ | |
72 | |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
73 ngx_http_v3_create_srv_conf, /* create server configuration */ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
74 ngx_http_v3_merge_srv_conf, /* merge server configuration */ |
7681 | 75 |
8015 | 76 ngx_http_v3_create_loc_conf, /* create location configuration */ |
77 ngx_http_v3_merge_loc_conf /* merge location configuration */ | |
7681 | 78 }; |
79 | |
80 | |
81 ngx_module_t ngx_http_v3_module = { | |
82 NGX_MODULE_V1, | |
83 &ngx_http_v3_module_ctx, /* module context */ | |
84 ngx_http_v3_commands, /* module directives */ | |
85 NGX_HTTP_MODULE, /* module type */ | |
86 NULL, /* init master */ | |
87 NULL, /* init module */ | |
88 NULL, /* init process */ | |
89 NULL, /* init thread */ | |
90 NULL, /* exit thread */ | |
91 NULL, /* exit process */ | |
92 NULL, /* exit master */ | |
93 NGX_MODULE_V1_PADDING | |
94 }; | |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
95 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
96 |
7714
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
97 static ngx_http_variable_t ngx_http_v3_vars[] = { |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
98 |
8011
e533a352d118
Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
99 { ngx_string("http3"), NULL, ngx_http_variable_http3, 0, 0, 0 }, |
7763
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
100 |
7714
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
101 ngx_http_null_variable |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
102 }; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
103 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
104 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
105 static ngx_int_t |
7763
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
106 ngx_http_variable_http3(ngx_http_request_t *r, |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
107 ngx_http_variable_value_t *v, uintptr_t data) |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
108 { |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
109 v->valid = 1; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
110 v->no_cacheable = 1; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
111 v->not_found = 0; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
112 |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
113 v->data = ngx_pnalloc(r->pool, sizeof("h3-xx") - 1); |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
114 if (v->data == NULL) { |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
115 return NGX_ERROR; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
116 } |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
117 |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
118 v->len = ngx_sprintf(v->data, "h3-%d", NGX_QUIC_DRAFT_VERSION) - v->data; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
119 |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
120 return NGX_OK; |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
121 } |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
122 |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
123 |
0b95c2041887
HTTP/3: http3 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
124 static ngx_int_t |
7714
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
125 ngx_http_v3_add_variables(ngx_conf_t *cf) |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
126 { |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
127 ngx_http_variable_t *var, *v; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
128 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
129 for (v = ngx_http_v3_vars; v->name.len; v++) { |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
130 var = ngx_http_add_variable(cf, &v->name, v->flags); |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
131 if (var == NULL) { |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
132 return NGX_ERROR; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
133 } |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
134 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
135 var->get_handler = v->get_handler; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
136 var->data = v->data; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
137 } |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
138 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
139 return NGX_OK; |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
140 } |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
141 |
abb7c1a4c9d5
Adedd the http "quic" variable.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
142 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
143 static void * |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
144 ngx_http_v3_create_srv_conf(ngx_conf_t *cf) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
145 { |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
146 ngx_http_v3_srv_conf_t *h3scf; |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
147 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
148 h3scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_srv_conf_t)); |
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
149 if (h3scf == NULL) { |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
150 return NULL; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
151 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
152 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
153 h3scf->max_table_capacity = NGX_CONF_UNSET_SIZE; |
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
154 h3scf->max_blocked_streams = NGX_CONF_UNSET_UINT; |
8015 | 155 h3scf->max_concurrent_pushes = NGX_CONF_UNSET_UINT; |
7949
032cb35ce758
HTTP/3: http3_max_field_size directive to limit string size.
Roman Arutyunyan <arut@nginx.com>
parents:
7912
diff
changeset
|
156 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
157 return h3scf; |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
158 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
159 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
160 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
161 static char * |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
162 ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
163 { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
164 ngx_http_v3_srv_conf_t *prev = parent; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
165 ngx_http_v3_srv_conf_t *conf = child; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7681
diff
changeset
|
166 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
167 ngx_conf_merge_size_value(conf->max_table_capacity, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
168 prev->max_table_capacity, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
169 NGX_HTTP_V3_DEFAULT_MAX_TABLE_CAPACITY); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
170 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
171 ngx_conf_merge_uint_value(conf->max_blocked_streams, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
172 prev->max_blocked_streams, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
173 NGX_HTTP_V3_DEFAULT_MAX_BLOCKED_STREAMS); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7949
diff
changeset
|
174 |
8015 | 175 ngx_conf_merge_uint_value(conf->max_concurrent_pushes, |
176 prev->max_concurrent_pushes, | |
177 NGX_HTTP_V3_DEFAULT_MAX_CONCURRENT_PUSHES); | |
178 | |
179 return NGX_CONF_OK; | |
180 } | |
181 | |
182 | |
183 static void * | |
184 ngx_http_v3_create_loc_conf(ngx_conf_t *cf) | |
185 { | |
186 ngx_http_v3_loc_conf_t *h3lcf; | |
187 | |
188 h3lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_loc_conf_t)); | |
189 if (h3lcf == NULL) { | |
190 return NULL; | |
191 } | |
192 | |
193 /* | |
194 * set by ngx_pcalloc(): | |
195 * | |
196 * h3lcf->pushes = NULL; | |
197 */ | |
198 | |
199 h3lcf->push_preload = NGX_CONF_UNSET; | |
200 h3lcf->push = NGX_CONF_UNSET; | |
201 | |
202 return h3lcf; | |
203 } | |
204 | |
205 | |
206 static char * | |
207 ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
208 { | |
209 ngx_http_v3_loc_conf_t *prev = parent; | |
210 ngx_http_v3_loc_conf_t *conf = child; | |
211 | |
212 ngx_conf_merge_value(conf->push, prev->push, 1); | |
213 | |
214 if (conf->push && conf->pushes == NULL) { | |
215 conf->pushes = prev->pushes; | |
216 } | |
217 | |
218 ngx_conf_merge_value(conf->push_preload, prev->push_preload, 0); | |
219 | |
7830
036164360fa9
HTTP/3: directives with limited values converted to post handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7829
diff
changeset
|
220 return NGX_CONF_OK; |
036164360fa9
HTTP/3: directives with limited values converted to post handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7829
diff
changeset
|
221 } |
8015 | 222 |
223 | |
224 static char * | |
225 ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
226 { | |
227 ngx_http_v3_loc_conf_t *h3lcf = conf; | |
228 | |
229 ngx_str_t *value; | |
230 ngx_http_complex_value_t *cv; | |
231 ngx_http_compile_complex_value_t ccv; | |
232 | |
233 value = cf->args->elts; | |
234 | |
235 if (ngx_strcmp(value[1].data, "off") == 0) { | |
236 | |
237 if (h3lcf->pushes) { | |
238 return "\"off\" parameter cannot be used with URI"; | |
239 } | |
240 | |
241 if (h3lcf->push == 0) { | |
242 return "is duplicate"; | |
243 } | |
244 | |
245 h3lcf->push = 0; | |
246 return NGX_CONF_OK; | |
247 } | |
248 | |
249 if (h3lcf->push == 0) { | |
250 return "URI cannot be used with \"off\" parameter"; | |
251 } | |
252 | |
253 h3lcf->push = 1; | |
254 | |
255 if (h3lcf->pushes == NULL) { | |
256 h3lcf->pushes = ngx_array_create(cf->pool, 1, | |
257 sizeof(ngx_http_complex_value_t)); | |
258 if (h3lcf->pushes == NULL) { | |
259 return NGX_CONF_ERROR; | |
260 } | |
261 } | |
262 | |
263 cv = ngx_array_push(h3lcf->pushes); | |
264 if (cv == NULL) { | |
265 return NGX_CONF_ERROR; | |
266 } | |
267 | |
268 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
269 | |
270 ccv.cf = cf; | |
271 ccv.value = &value[1]; | |
272 ccv.complex_value = cv; | |
273 | |
274 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
275 return NGX_CONF_ERROR; | |
276 } | |
277 | |
278 return NGX_CONF_OK; | |
279 } |