diff options
author | Sergey Kandaurov <pluknet@nginx.com> | 2020-03-28 18:41:31 +0300 |
---|---|---|
committer | Sergey Kandaurov <pluknet@nginx.com> | 2020-03-28 18:41:31 +0300 |
commit | 4502e5b1e98412ae261d3440e2962519e3e71d5d (patch) | |
tree | 8eb6471227c9b9ac77aed4676f5dcf1e6711b6cf | |
parent | 7a0b840c51f7ed60453d7fb06731ae024295327b (diff) | |
download | nginx-4502e5b1e98412ae261d3440e2962519e3e71d5d.tar.gz nginx-4502e5b1e98412ae261d3440e2962519e3e71d5d.zip |
HTTP/3: http3 variable.
-rw-r--r-- | src/http/v3/ngx_http_v3_module.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c index 45bfc5b1c..279210337 100644 --- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -102,6 +102,8 @@ static ngx_command_t ngx_http_v3_commands[] = { static ngx_int_t ngx_http_variable_quic(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_http3(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf); static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, @@ -143,6 +145,9 @@ static ngx_http_variable_t ngx_http_v3_vars[] = { { ngx_string("quic"), NULL, ngx_http_variable_quic, 0, 0, 0 }, + { ngx_string("http3"), NULL, ngx_http_variable_http3, + 0, 0, 0 }, + ngx_http_null_variable }; @@ -168,6 +173,25 @@ ngx_http_variable_quic(ngx_http_request_t *r, static ngx_int_t +ngx_http_variable_http3(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + v->valid = 1; + v->no_cacheable = 1; + v->not_found = 0; + + v->data = ngx_pnalloc(r->pool, sizeof("h3-xx") - 1); + if (v->data == NULL) { + return NGX_ERROR; + } + + v->len = ngx_sprintf(v->data, "h3-%d", NGX_QUIC_DRAFT_VERSION) - v->data; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf) { ngx_http_variable_t *var, *v; |