Opened 7 years ago

Closed 6 years ago

#1415 closed defect (invalid)

HTTP/2 log status as 000, when client send invalid data, like "exceeded http2_max_field_size limit"

Reported by: crasyangel.lhy@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.12.x
Keywords: Cc:
uname -a: 2.6.32_1-16-0-0_virtio
nginx -V: nginx version: nginx/1.12.2

Description

HTTP/2 log status as 000, when client send invalid data, like "exceeded http2_max_field_size limit"

I want to submit a patch, record r->err_status when client error happen, and would only work in ngx_http_log_request during ngx_http_v2_close_stream without ngx_http_finalize_request

Gao Yan
China
Thx.

diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
old mode 100644
new mode 100755
index 55db58e7..d49c9aba
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -1872,6 +1872,8 @@ ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, u_char *pos,

ngx_connection_t *fc;
ngx_http_v2_node_t *node;
ngx_http_v2_stream_t *stream;

+ ngx_http_request_t *r;
+

if (h2c->state.length != NGX_HTTP_V2_RST_STREAM_SIZE) {

ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,

@@ -1915,7 +1917,8 @@ ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, u_char *pos,

stream->in_closed = 1;
stream->out_closed = 1;

  • fc = stream->request->connection;

+ r = stream->request;
+ fc = r->connection;

fc->error = 1;

switch (status) {

@@ -1938,6 +1941,7 @@ ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, u_char *pos,

break;

}

+ r->err_status = NGX_HTTP_CLIENT_CLOSED_REQUEST;

ev = fc->read;
ev->handler(ev);

@@ -3945,8 +3949,9 @@ static ngx_int_t

ngx_http_v2_terminate_stream(ngx_http_v2_connection_t *h2c,

ngx_http_v2_stream_t *stream, ngx_uint_t status)

{

  • ngx_event_t *rev;
  • ngx_connection_t *fc;

+ ngx_event_t *rev;
+ ngx_connection_t *fc;
+ ngx_http_request_t *r;

if (stream->rst_sent) {

return NGX_OK;

@@ -3961,7 +3966,9 @@ ngx_http_v2_terminate_stream(ngx_http_v2_connection_t *h2c,

stream->rst_sent = 1;
stream->skip_data = 1;

  • fc = stream->request->connection;

+ r = stream->request;
+ r->err_status = NGX_HTTP_BAD_REQUEST;
+ fc = r->connection;

fc->error = 1;

rev = fc->read;

@@ -4266,8 +4273,23 @@ ngx_http_v2_finalize_connection(ngx_http_v2_connection_t *h2c,

stream->waiting = 0;

r = stream->request;

  • fc = r->connection;

+ switch (status) {
+ case NGX_HTTP_V2_PROTOCOL_ERROR:
+ case NGX_HTTP_V2_FLOW_CTRL_ERROR:
+ case NGX_HTTP_V2_SIZE_ERROR:
+ case NGX_HTTP_V2_COMP_ERROR:
+ case NGX_HTTP_V2_CONNECT_ERROR:
+ case NGX_HTTP_V2_ENHANCE_YOUR_CALM:
+ r->err_status = NGX_HTTP_BAD_REQUEST;
+ break;
+
+ case NGX_HTTP_V2_INTERNAL_ERROR:
+ r->err_status = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ break;
+ }
+
+ fc = r->connection;

fc->error = 1;

if (stream->queued) {

Change History (1)

comment:1 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: newclosed

Please see http://nginx.org/en/docs/contributing_changes.html for recommendations on how to submit patches to nginx.

Note: See TracTickets for help on using tickets.