Nginx use temp file as request body in post subrequest

salmaanp nginx-forum at forum.nginx.org
Wed Mar 10 23:09:22 UTC 2021


I guess we still need the request buf, so made these changes which seemed
better. but the behavior is still same. Went though the code for upstream
create request and looks like  the body is always read from buffer.

    ngx_buf_t *payload_buf = NULL;

    payload_buf = ngx_create_temp_buf(r->pool, ctx->temp_buf_size);
    if (payload_buf == NULL) {
        ngx_log_stderr(0, "failed to ngx_create_temp_buf");
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
    }
    payload_buf->in_file = 1;
    payload_buf->temp_file = 1;
    payload_buf->file = &ctx->test_temp_file->file;

    sr->request_body->buf = payload_buf;
    sr->request_body->bufs->next = NULL;
    sr->request_body->bufs->buf = payload_buf;
    sr->header_only = 1;
    //sr->filter_need_in_memory = 1;

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,290940,290941#msg-290941



More information about the nginx mailing list