Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix received and size same issue when using HTTP/2 #55

Merged
merged 1 commit into from
Dec 24, 2021

Conversation

e2dk4r
Copy link
Contributor

@e2dk4r e2dk4r commented Dec 16, 2021

this changes fix received value same as size value in responses when using HTTP/2

bug mentioned at #45

Copy link
Owner

@masterzen masterzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the time to test it right now though, but it seems interesting.

@e2dk4r
Copy link
Contributor Author

e2dk4r commented Dec 16, 2021

The reason this bug accours is request body rb->rest is returning 1 when HTTP/2 is enabled.
You can find this in src/http/v2/ngx_http_v2.c in ngx_http_v2_read_request_body function on rb->rest = 1; line.

ngx_int_t
ngx_http_v2_read_request_body(ngx_http_request_t *r)
{
    off_t                      len;
    size_t                     size;
    ngx_buf_t                 *buf;
    ngx_int_t                  rc;
    ngx_http_v2_stream_t      *stream;
    ngx_http_v2_srv_conf_t    *h2scf;
    ngx_http_request_body_t   *rb;
    ngx_http_core_loc_conf_t  *clcf;
    ngx_http_v2_connection_t  *h2c;


    stream = r->stream;
    rb = r->request_body;


    if (stream->skip_data) {
        r->request_body_no_buffering = 0;
        rb->post_handler(r);
        return NGX_OK;
    }


    rb->rest = 1;
    ...

https://github.com/nginx/nginx/blob/e0086aaeea3810b5485f53d2f38f74cc74effea7/src/http/v2/ngx_http_v2.c#L4009-L4031

@e2dk4r e2dk4r requested a review from masterzen December 24, 2021 08:41
Copy link
Owner

@masterzen masterzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't actually tested the code, but this looks correct.
It can't be worst than the actual behavior :)

@masterzen masterzen merged commit 68b3ab3 into masterzen:master Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants