comparison src/http/v3/ngx_http_v3_module.c @ 8297:0b95c2041887 quic

HTTP/3: http3 variable.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 28 Mar 2020 18:41:31 +0300
parents 8e54a17dabee
children 0f9e9786b90d
comparison
equal deleted inserted replaced
8296:f11b7981a03d 8297:0b95c2041887
99 ngx_null_command 99 ngx_null_command
100 }; 100 };
101 101
102 102
103 static ngx_int_t ngx_http_variable_quic(ngx_http_request_t *r, 103 static ngx_int_t ngx_http_variable_quic(ngx_http_request_t *r,
104 ngx_http_variable_value_t *v, uintptr_t data);
105 static ngx_int_t ngx_http_variable_http3(ngx_http_request_t *r,
104 ngx_http_variable_value_t *v, uintptr_t data); 106 ngx_http_variable_value_t *v, uintptr_t data);
105 static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf); 107 static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf);
106 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); 108 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf);
107 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, 109 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf,
108 void *parent, void *child); 110 void *parent, void *child);
141 143
142 static ngx_http_variable_t ngx_http_v3_vars[] = { 144 static ngx_http_variable_t ngx_http_v3_vars[] = {
143 { ngx_string("quic"), NULL, ngx_http_variable_quic, 145 { ngx_string("quic"), NULL, ngx_http_variable_quic,
144 0, 0, 0 }, 146 0, 0, 0 },
145 147
148 { ngx_string("http3"), NULL, ngx_http_variable_http3,
149 0, 0, 0 },
150
146 ngx_http_null_variable 151 ngx_http_null_variable
147 }; 152 };
148 153
149 154
150 static ngx_int_t 155 static ngx_int_t
160 v->data = (u_char *) "quic"; 165 v->data = (u_char *) "quic";
161 return NGX_OK; 166 return NGX_OK;
162 } 167 }
163 168
164 v->not_found = 1; 169 v->not_found = 1;
170
171 return NGX_OK;
172 }
173
174
175 static ngx_int_t
176 ngx_http_variable_http3(ngx_http_request_t *r,
177 ngx_http_variable_value_t *v, uintptr_t data)
178 {
179 v->valid = 1;
180 v->no_cacheable = 1;
181 v->not_found = 0;
182
183 v->data = ngx_pnalloc(r->pool, sizeof("h3-xx") - 1);
184 if (v->data == NULL) {
185 return NGX_ERROR;
186 }
187
188 v->len = ngx_sprintf(v->data, "h3-%d", NGX_QUIC_DRAFT_VERSION) - v->data;
165 189
166 return NGX_OK; 190 return NGX_OK;
167 } 191 }
168 192
169 193