On Tue, Feb 13, 2018 at 11:58:40AM +, Alessandro Ghedini wrote:
> If it's of any help, I merged your patch and mine into one, which copies the
> headers (excluding Accept) into PUSH_PROMISE and r->headers_in like my
> original
> patch did, as well as HPACK encode them into PUSH_PROMISE instead of writing
> them as literal strings, as your patch did. This fixes the problems I
> mentioned
> in my previous email.
To keep you updated, we're cultivating these patches:
# HG changeset patch
# User Ruslan Ermilov
# Date 1518609549 -10800
# Wed Feb 14 14:59:09 2018 +0300
# Node ID 9cd08f096c366771ffbebd2872883be04903d425
# Parent 8b0553239592f5d0fd419e5116b9d343838685cf
Expose more headers with NGX_HTTP_HEADERS.
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -140,7 +140,7 @@ ngx_http_header_t ngx_http_headers_in[]
offsetof(ngx_http_headers_in_t, upgrade),
ngx_http_process_header_line },
-#if (NGX_HTTP_GZIP)
+#if (NGX_HTTP_GZIP || NGX_HTTP_HEADERS)
{ ngx_string("Accept-Encoding"),
offsetof(ngx_http_headers_in_t, accept_encoding),
ngx_http_process_header_line },
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -200,7 +200,7 @@ typedef struct {
ngx_table_elt_t *expect;
ngx_table_elt_t *upgrade;
-#if (NGX_HTTP_GZIP)
+#if (NGX_HTTP_GZIP || NGX_HTTP_HEADERS)
ngx_table_elt_t *accept_encoding;
ngx_table_elt_t *via;
#endif
# HG changeset patch
# User Ruslan Ermilov
# Date 1518634812 -10800
# Wed Feb 14 22:00:12 2018 +0300
# Node ID cd54884b375b70ecd358358e5e78f43e70b6163a
# Parent 9cd08f096c366771ffbebd2872883be04903d425
HTTP/2: push additional request headers (closes #1478).
The Accept-Encoding, Accept-Language, and User-Agent header fields
are now copied from the original request to pushed requests.
diff --git a/auto/modules b/auto/modules
--- a/auto/modules
+++ b/auto/modules
@@ -420,6 +420,7 @@ if [ $HTTP = YES ]; then
if [ $HTTP_V2 = YES ]; then
have=NGX_HTTP_V2 . auto/have
+have=NGX_HTTP_HEADERS . auto/have
ngx_module_name=ngx_http_v2_module
ngx_module_incs=src/http/v2
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -11,6 +11,14 @@
#include
+typedef struct {
+ngx_str_t name;
+ngx_uint_t offset;
+ngx_uint_t hash;
+ngx_http_header_t *hh;
+} ngx_http_v2_parse_header_t;
+
+
/* errors */
#define NGX_HTTP_V2_NO_ERROR 0x0
#define NGX_HTTP_V2_PROTOCOL_ERROR 0x1
@@ -156,6 +164,8 @@ static ngx_int_t ngx_http_v2_parse_schem
ngx_str_t *value);
static ngx_int_t ngx_http_v2_parse_authority(ngx_http_request_t *r,
ngx_str_t *value);
+static ngx_int_t ngx_http_v2_parse_header(ngx_http_request_t *r,
+ngx_http_v2_parse_header_t *header, ngx_str_t *value);
static ngx_int_t ngx_http_v2_construct_request_line(ngx_http_request_t *r);
static ngx_int_t ngx_http_v2_cookie(ngx_http_request_t *r,
ngx_http_v2_header_t *header);
@@ -201,6 +211,23 @@ static ngx_http_v2_handler_pt ngx_http_v
(sizeof(ngx_http_v2_frame_states) / sizeof(ngx_http_v2_handler_pt))
+static ngx_http_v2_parse_header_t ngx_http_v2_parse_headers[] = {
+{ ngx_string("host"),
+ offsetof(ngx_http_headers_in_t, host), 0, NULL },
+
+{ ngx_string("accept-encoding"),
+ offsetof(ngx_http_headers_in_t, accept_encoding), 0, NULL },
+
+{ ngx_string("accept-language"),
+ offsetof(ngx_http_headers_in_t, accept_language), 0, NULL },
+
+{ ngx_string("user-agent"),
+ offsetof(ngx_http_headers_in_t, user_agent), 0, NULL },
+
+{ ngx_null_string, 0, 0, NULL }
+};
+
+
void
ngx_http_v2_init(ngx_event_t *rev)
{
@@ -2514,21 +2541,25 @@ ngx_http_v2_parse_int(ngx_http_v2_connec
}
-ngx_int_t
-ngx_http_v2_push_stream(ngx_http_v2_connection_t *h2c, ngx_uint_t depend,
-size_t request_length, ngx_str_t *path, ngx_str_t *authority)
+ngx_http_v2_stream_t *
+ngx_http_v2_push_stream(ngx_http_v2_stream_t *parent, ngx_str_t *path)
{
-ngx_int_t rc;
-ngx_str_t value;
-ngx_connection_t *fc;
-ngx_http_request_t*r;
-ngx_http_v2_node_t*node;
-ngx_http_v2_stream_t *stream;
+ngx_int_t rc;
+ngx_str_t value;
+ngx_table_elt_t **h;
+ngx_connection_t *fc;
+ngx_http_request_t *r;
+ngx_http_v2_node_t *node;
+ngx_http_v2_stream_t *stream;
+ngx_http_v2_connection_t *h2c;
+ngx_http_v2_parse_header_t *header;
+
+h2c = parent->connection;
node = ngx_htt