comparison src/http/v3/ngx_http_v3_module.c @ 8489:f0882db8c8d4 quic

HTTP/3: removed $http3 that served its purpose. To specify final protocol version by hand: add_header Alt-Svc h3=":443";
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 31 May 2021 11:54:47 +0300
parents ae2e68f206f9
children 054f9be0aaf9
comparison
equal deleted inserted replaced
8488:8422570f6af4 8489:f0882db8c8d4
8 #include <ngx_config.h> 8 #include <ngx_config.h>
9 #include <ngx_core.h> 9 #include <ngx_core.h>
10 #include <ngx_http.h> 10 #include <ngx_http.h>
11 11
12 12
13 static ngx_int_t ngx_http_variable_http3(ngx_http_request_t *r,
14 ngx_http_variable_value_t *v, uintptr_t data);
15 static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf);
16 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); 13 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf);
17 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, 14 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent,
18 void *child); 15 void *child);
19 static void *ngx_http_v3_create_loc_conf(ngx_conf_t *cf); 16 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, 17 static char *ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent,
62 ngx_null_command 59 ngx_null_command
63 }; 60 };
64 61
65 62
66 static ngx_http_module_t ngx_http_v3_module_ctx = { 63 static ngx_http_module_t ngx_http_v3_module_ctx = {
67 ngx_http_v3_add_variables, /* preconfiguration */ 64 NULL, /* preconfiguration */
68 NULL, /* postconfiguration */ 65 NULL, /* postconfiguration */
69 66
70 NULL, /* create main configuration */ 67 NULL, /* create main configuration */
71 NULL, /* init main configuration */ 68 NULL, /* init main configuration */
72 69
92 NULL, /* exit master */ 89 NULL, /* exit master */
93 NGX_MODULE_V1_PADDING 90 NGX_MODULE_V1_PADDING
94 }; 91 };
95 92
96 93
97 static ngx_http_variable_t ngx_http_v3_vars[] = {
98
99 { ngx_string("http3"), NULL, ngx_http_variable_http3, 0, 0, 0 },
100
101 ngx_http_null_variable
102 };
103
104
105 static ngx_int_t
106 ngx_http_variable_http3(ngx_http_request_t *r,
107 ngx_http_variable_value_t *v, uintptr_t data)
108 {
109 v->valid = 1;
110 v->no_cacheable = 1;
111 v->not_found = 0;
112
113 v->data = ngx_pnalloc(r->pool, sizeof("h3-xx") - 1);
114 if (v->data == NULL) {
115 return NGX_ERROR;
116 }
117
118 v->len = ngx_sprintf(v->data, "h3-%d", NGX_QUIC_DRAFT_VERSION) - v->data;
119
120 return NGX_OK;
121 }
122
123
124 static ngx_int_t
125 ngx_http_v3_add_variables(ngx_conf_t *cf)
126 {
127 ngx_http_variable_t *var, *v;
128
129 for (v = ngx_http_v3_vars; v->name.len; v++) {
130 var = ngx_http_add_variable(cf, &v->name, v->flags);
131 if (var == NULL) {
132 return NGX_ERROR;
133 }
134
135 var->get_handler = v->get_handler;
136 var->data = v->data;
137 }
138
139 return NGX_OK;
140 }
141
142
143 static void * 94 static void *
144 ngx_http_v3_create_srv_conf(ngx_conf_t *cf) 95 ngx_http_v3_create_srv_conf(ngx_conf_t *cf)
145 { 96 {
146 ngx_http_v3_srv_conf_t *h3scf; 97 ngx_http_v3_srv_conf_t *h3scf;
147 98