mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Request body: recalculate size of a request body in scgi module.
This allows to handle requests with chunked body by scgi module, and also simplifies handling of various request body modifications.
This commit is contained in:
parent
0ce5a3aa18
commit
d60b8d10f0
@ -533,10 +533,11 @@ ngx_http_scgi_create_key(ngx_http_request_t *r)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_scgi_create_request(ngx_http_request_t *r)
|
ngx_http_scgi_create_request(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
|
off_t content_length_n;
|
||||||
u_char ch, *key, *val, *lowcase_key;
|
u_char ch, *key, *val, *lowcase_key;
|
||||||
size_t len, key_len, val_len, allocated;
|
size_t len, key_len, val_len, allocated;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_str_t *content_length;
|
ngx_str_t content_length;
|
||||||
ngx_uint_t i, n, hash, skip_empty, header_params;
|
ngx_uint_t i, n, hash, skip_empty, header_params;
|
||||||
ngx_chain_t *cl, *body;
|
ngx_chain_t *cl, *body;
|
||||||
ngx_list_part_t *part;
|
ngx_list_part_t *part;
|
||||||
@ -545,12 +546,20 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
|
|||||||
ngx_http_script_engine_t e, le;
|
ngx_http_script_engine_t e, le;
|
||||||
ngx_http_scgi_loc_conf_t *scf;
|
ngx_http_scgi_loc_conf_t *scf;
|
||||||
ngx_http_script_len_code_pt lcode;
|
ngx_http_script_len_code_pt lcode;
|
||||||
static ngx_str_t zero = ngx_string("0");
|
u_char buffer[NGX_OFF_T_LEN];
|
||||||
|
|
||||||
content_length = r->headers_in.content_length ?
|
content_length_n = 0;
|
||||||
&r->headers_in.content_length->value : &zero;
|
body = r->upstream->request_bufs;
|
||||||
|
|
||||||
len = sizeof("CONTENT_LENGTH") + content_length->len + 1;
|
while (body) {
|
||||||
|
content_length_n += ngx_buf_size(body->buf);
|
||||||
|
body = body->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
content_length.data = buffer;
|
||||||
|
content_length.len = ngx_sprintf(buffer, "%O", content_length_n) - buffer;
|
||||||
|
|
||||||
|
len = sizeof("CONTENT_LENGTH") + content_length.len + 1;
|
||||||
|
|
||||||
header_params = 0;
|
header_params = 0;
|
||||||
ignored = NULL;
|
ignored = NULL;
|
||||||
@ -672,11 +681,8 @@ ngx_http_scgi_create_request(ngx_http_request_t *r)
|
|||||||
|
|
||||||
cl->buf = b;
|
cl->buf = b;
|
||||||
|
|
||||||
b->last = ngx_snprintf(b->last,
|
b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z",
|
||||||
NGX_SIZE_T_LEN + 1 + sizeof("CONTENT_LENGTH")
|
len, &content_length);
|
||||||
+ NGX_OFF_T_LEN + 1,
|
|
||||||
"%ui:CONTENT_LENGTH%Z%V%Z",
|
|
||||||
len, content_length);
|
|
||||||
|
|
||||||
if (scf->params_len) {
|
if (scf->params_len) {
|
||||||
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user