You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nginx_hpack_push_fix.patch 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. diff --git a/src/http/v2/ngx_http_v2.h b/src/http/v2/ngx_http_v2.h
  2. index ae826af..41086a6 100644
  3. --- a/src/http/v2/ngx_http_v2.h
  4. +++ b/src/http/v2/ngx_http_v2.h
  5. @@ -490,4 +490,8 @@ ngx_http_v2_table_resize(ngx_http_v2_connection_t *h2c);
  6. ngx_http_v2_write_header(h2c, pos, (u_char *) key, sizeof(key) - 1, \
  7. val.data, val.len, tmp);
  8. +#define ngx_http_v2_write_header_pot(key, val) \
  9. + ngx_http_v2_write_header(h2c, pos, (u_char *) key, sizeof(key) - 1, \
  10. + val->data, val->len, tmp);
  11. +
  12. #endif /* _NGX_HTTP_V2_H_INCLUDED_ */
  13. diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c
  14. index 6a210d4..8a59424 100644
  15. --- a/src/http/v2/ngx_http_v2_filter_module.c
  16. +++ b/src/http/v2/ngx_http_v2_filter_module.c
  17. @@ -59,6 +59,17 @@
  18. #define NGX_HTTP_V2_NO_TRAILERS (ngx_http_v2_out_frame_t *) -1
  19. +static const struct {
  20. + u_char *name;
  21. + u_char const len;
  22. +} push_header[] = {
  23. + { (u_char*)":authority" , 10 },
  24. + { (u_char*)"accept-encoding" , 15 },
  25. + { (u_char*)"accept-language" , 15 },
  26. + { (u_char*)"user-agent" , 10 }
  27. +};
  28. +
  29. +
  30. typedef struct {
  31. ngx_str_t name;
  32. u_char index;
  33. @@ -955,6 +966,7 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
  34. for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) {
  35. len += binary[i].len;
  36. + len += push_header[i].len + 1;
  37. }
  38. pos = ngx_pnalloc(r->pool, len);
  39. @@ -964,12 +976,17 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
  40. start = pos;
  41. - if (h2c->table_update) {
  42. - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
  43. - "http2 table size update: 0");
  44. - *pos++ = (1 << 5) | 0;
  45. - h2c->table_update = 0;
  46. - }
  47. + h2c = r->stream->connection;
  48. +
  49. + if (h2c->indicate_resize) {
  50. + *pos = 32;
  51. + pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(5),
  52. + h2c->max_hpack_table_size);
  53. + h2c->indicate_resize = 0;
  54. +#if (NGX_HTTP_V2_HPACK_ENC)
  55. + ngx_http_v2_table_resize(h2c);
  56. +#endif
  57. + }
  58. ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
  59. "http2 push header: \":method: GET\"");
  60. @@ -979,8 +996,7 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
  61. ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
  62. "http2 push header: \":path: %V\"", path);
  63. - *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_PATH_INDEX);
  64. - pos = ngx_http_v2_write_value(pos, path->data, path->len, tmp);
  65. + pos = ngx_http_v2_write_header_pot(":path", path);
  66. #if (NGX_HTTP_SSL)
  67. if (fc->ssl) {
  68. @@ -1003,11 +1019,15 @@ ngx_http_v2_push_resource(ngx_http_request_t *r, ngx_str_t *path,
  69. continue;
  70. }
  71. + value = &(*h)->value;
  72. +
  73. ngx_log_debug2(NGX_LOG_DEBUG_HTTP, fc->log, 0,
  74. "http2 push header: \"%V: %V\"",
  75. &ph[i].name, &(*h)->value);
  76. - pos = ngx_cpymem(pos, binary[i].data, binary[i].len);
  77. + pos = ngx_http_v2_write_header(h2c, pos,
  78. + push_header[i].name, push_header[i].len, value->data, value->len,
  79. + tmp);
  80. }
  81. frame = ngx_http_v2_create_push_frame(r, start, pos);