aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_chunked_filter_module.c58
-rw-r--r--src/http/modules/ngx_http_ssl_module.c22
2 files changed, 64 insertions, 16 deletions
diff --git a/src/http/modules/ngx_http_chunked_filter_module.c b/src/http/modules/ngx_http_chunked_filter_module.c
index 4d6fd3eed..87b032496 100644
--- a/src/http/modules/ngx_http_chunked_filter_module.c
+++ b/src/http/modules/ngx_http_chunked_filter_module.c
@@ -18,7 +18,7 @@ typedef struct {
static ngx_int_t ngx_http_chunked_filter_init(ngx_conf_t *cf);
static ngx_chain_t *ngx_http_chunked_create_trailers(ngx_http_request_t *r,
- ngx_http_chunked_filter_ctx_t *ctx);
+ ngx_http_chunked_filter_ctx_t *ctx, size_t size);
static ngx_http_module_t ngx_http_chunked_filter_module_ctx = {
@@ -106,6 +106,7 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
u_char *chunk;
off_t size;
+ size_t n;
ngx_int_t rc;
ngx_buf_t *b;
ngx_chain_t *out, *cl, *tl, **ll;
@@ -161,29 +162,50 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
chunk = b->start;
if (chunk == NULL) {
- /* the "0000000000000000" is 64-bit hexadecimal string */
- chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1);
+#if (NGX_HTTP_V3)
+ if (r->http_version == NGX_HTTP_VERSION_30) {
+ n = NGX_HTTP_V3_VARLEN_INT_LEN * 2;
+
+ } else
+#endif
+ {
+ /* the "0000000000000000" is 64-bit hexadecimal string */
+ n = sizeof("0000000000000000" CRLF) - 1;
+ }
+
+ chunk = ngx_palloc(r->pool, n);
if (chunk == NULL) {
return NGX_ERROR;
}
b->start = chunk;
- b->end = chunk + sizeof("0000000000000000" CRLF) - 1;
+ b->end = chunk + n;
}
b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
b->memory = 0;
b->temporary = 1;
b->pos = chunk;
- b->last = ngx_sprintf(chunk, "%xO" CRLF, size);
+
+#if (NGX_HTTP_V3)
+ if (r->http_version == NGX_HTTP_VERSION_30) {
+ b->last = (u_char *) ngx_http_v3_encode_varlen_int(chunk,
+ NGX_HTTP_V3_FRAME_DATA);
+ b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, size);
+
+ } else
+#endif
+ {
+ b->last = ngx_sprintf(chunk, "%xO" CRLF, size);
+ }
tl->next = out;
out = tl;
}
if (cl->buf->last_buf) {
- tl = ngx_http_chunked_create_trailers(r, ctx);
+ tl = ngx_http_chunked_create_trailers(r, ctx, size);
if (tl == NULL) {
return NGX_ERROR;
}
@@ -192,11 +214,12 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
*ll = tl;
- if (size == 0) {
- tl->buf->pos += 2;
- }
-
- } else if (size > 0) {
+ } else if (size > 0
+#if (NGX_HTTP_V3)
+ && r->http_version != NGX_HTTP_VERSION_30
+#endif
+ )
+ {
tl = ngx_chain_get_free_buf(r->pool, &ctx->free);
if (tl == NULL) {
return NGX_ERROR;
@@ -227,7 +250,7 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
static ngx_chain_t *
ngx_http_chunked_create_trailers(ngx_http_request_t *r,
- ngx_http_chunked_filter_ctx_t *ctx)
+ ngx_http_chunked_filter_ctx_t *ctx, size_t size)
{
size_t len;
ngx_buf_t *b;
@@ -236,6 +259,12 @@ ngx_http_chunked_create_trailers(ngx_http_request_t *r,
ngx_list_part_t *part;
ngx_table_elt_t *header;
+#if (NGX_HTTP_V3)
+ if (r->http_version == NGX_HTTP_VERSION_30) {
+ return ngx_http_v3_create_trailers(r);
+ }
+#endif
+
len = 0;
part = &r->headers_out.trailers.part;
@@ -288,7 +317,10 @@ ngx_http_chunked_create_trailers(ngx_http_request_t *r,
b->last = b->pos;
- *b->last++ = CR; *b->last++ = LF;
+ if (size > 0) {
+ *b->last++ = CR; *b->last++ = LF;
+ }
+
*b->last++ = '0';
*b->last++ = CR; *b->last++ = LF;
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index d7072a626..7daa4daf2 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -402,7 +402,7 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
#if (NGX_DEBUG)
unsigned int i;
#endif
-#if (NGX_HTTP_V2)
+#if (NGX_HTTP_V2 || NGX_HTTP_V3)
ngx_http_connection_t *hc;
#endif
#if (NGX_HTTP_V2 || NGX_DEBUG)
@@ -419,9 +419,11 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
}
#endif
-#if (NGX_HTTP_V2)
+#if (NGX_HTTP_V2 || NGX_HTTP_V3)
hc = c->data;
+#endif
+#if (NGX_HTTP_V2)
if (hc->addr_conf->http2) {
srv =
(unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
@@ -429,6 +431,12 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
} else
#endif
+#if (NGX_HTTP_V3)
+ if (hc->addr_conf->http3) {
+ srv = (unsigned char *) NGX_HTTP_V3_ALPN_ADVERTISE;
+ srvlen = sizeof(NGX_HTTP_V3_ALPN_ADVERTISE) - 1;
+ } else
+#endif
{
srv = (unsigned char *) NGX_HTTP_NPN_ADVERTISE;
srvlen = sizeof(NGX_HTTP_NPN_ADVERTISE) - 1;
@@ -1288,7 +1296,7 @@ ngx_http_ssl_init(ngx_conf_t *cf)
addr = port[p].addrs.elts;
for (a = 0; a < port[p].addrs.nelts; a++) {
- if (!addr[a].opt.ssl) {
+ if (!addr[a].opt.ssl && !addr[a].opt.http3) {
continue;
}
@@ -1302,6 +1310,14 @@ ngx_http_ssl_init(ngx_conf_t *cf)
cscf->file_name, cscf->line);
return NGX_ERROR;
}
+
+ if (addr[a].opt.http3 && !(sscf->protocols & NGX_SSL_TLSv1_3)) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "\"ssl_protocols\" did not enable TLSv1.3 for "
+ "the \"listen ... http3\" directive in %s:%ui",
+ cscf->file_name, cscf->line);
+ return NGX_ERROR;
+ }
}
}