Skip to content

Commit

Permalink
supported http/2 (part5.4): added request body reading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Jul 25, 2023
1 parent 0ae1f3f commit 357a2d4
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions ngx_http_proxy_connect_module.c
Expand Up @@ -721,14 +721,44 @@ ngx_http_v2_proxy_connect_send_connection_established(ngx_http_request_t *r)
r->write_event_handler = ngx_http_proxy_connect_write_downstream;
r->read_event_handler = ngx_http_proxy_connect_read_downstream;

/*
* If there is an upstream read event, we dont need to handle
* it actively here.
*
* We can read the client body data (DATA frame) actively here.
*/
/* init request_body for reading DATA frame from http2 */

#if 0
r->main->count--; /* ++ in ngx_http_read_client_request_body */
rc = ngx_http_read_client_request_body(r,
ngx_http_proxy_connect_read_downstream);

if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
ngx_http_proxy_connect_finalize_request(r, u, rc);
return;
}
#else
{
ngx_http_request_body_t *rb;

r->read_event_handler(r);
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));

if (rb == NULL) {
ngx_http_proxy_connect_finalize_request(r, u,
NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}

rb->rest = -1;
rb->post_handler = ngx_http_proxy_connect_read_downstream;

r->request_body = rb;

rc = ngx_http_v2_read_request_body(r);

if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
ngx_http_proxy_connect_finalize_request(r, u, rc);
return;
}

return;
}
#endif
}
#endif

Expand Down

0 comments on commit 357a2d4

Please sign in to comment.