The variable contains number of main quic connection (shared between streams). This is useful for keepalive tests.
src/http/v3/ngx_http_v3_module.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
# HG changeset patch # User Vladimir Khomutov <v...@wbsrv.ru> # Date 1703082840 -10800 # Wed Dec 20 17:34:00 2023 +0300 # Node ID 183d5a20c159a380d9a7562f3188d91aea465ab7 # Parent 1fb8eae095661a3fa1ce5598528d81dddc0811a6 HTTP/3: added $quic_connection variable. The variable contains number of main quic connection (shared between streams). This is useful for keepalive tests. diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c --- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -1,5 +1,6 @@ /* + * Copyright (C) 2023 Web Server LLC * Copyright (C) Nginx, Inc. * Copyright (C) Roman Arutyunyan */ @@ -12,6 +13,8 @@ static ngx_int_t ngx_http_v3_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_v3_quic_connection_variable(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, void *parent, @@ -117,6 +120,9 @@ static ngx_http_variable_t ngx_http_v3_ { ngx_string("http3"), NULL, ngx_http_v3_variable, 0, 0, 0 }, + { ngx_string("quic_connection"), NULL, ngx_http_v3_quic_connection_variable, + 0, 0, 0 }, + ngx_http_null_variable }; @@ -158,6 +164,40 @@ ngx_http_v3_variable(ngx_http_request_t static ngx_int_t +ngx_http_v3_quic_connection_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + u_char *p; + ngx_connection_t *c; + ngx_quic_stream_t *qs; + + if (r->connection->quic) { + qs = r->connection->quic; + + c = qs->parent; + + p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN); + if (p == NULL) { + return NGX_ERROR; + } + + v->len = ngx_sprintf(p, "%uA", c->number) - p; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = p; + + return NGX_OK; + } + + *v = ngx_http_variable_null_value; + + return NGX_OK; + +} + + +static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf) { ngx_http_variable_t *var, *v;
_______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel