May 18, 2019 05:10PM
Apologies if this is a trivial question. I have searched it on web and none of the answers have solved my problem. I am trying to read request body and thing seem to work fine if request body is small (4 kb). As soon as it becomes 4+ megabytes,ngx_http_read_client_request_body returns NGX_AGAIN (-2) in rc and my RequestBodyHandler is never called.

snippet of nginx.conf is like this for buffer settings. I have removed lot of other stuff from nginx.conf to keep it brief.

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

client_body_buffer_size 1m;
client_max_body_size 0;
}

/ * code sample start */
r->request_body_in_single_buf = 1;
r->request_body_in_persistent_file = 1;
r->request_body_in_clean_file = 1;
r->request_body_file_log_level = 0;

rc = ngx_http_read_client_request_body(r, RequestBodyHandler);
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {

CORE_TRACE(Error, L"Nginx read request error: %d", rc);
return from thread.
}

return NGX_DONE.

/ * code sample end */

Just to add some more context here. I use nginx thread pool. So my module's content handler basically queues a task to thread pool. Callback of thread eventually calls ngx_http_read_client_request_body to read request body. If there is an error (as stated in above if condition), thread simply returns and the completion handler of thread is called by nginx. In the completion handler, I do finalize request with NGX_DONE always.
Subject Author Posted

Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 18, 2019 05:10PM

Re: Reading large request body using ngx_http_read_client_request_body

Maxim Dounin May 20, 2019 10:00AM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 20, 2019 03:04PM

Re: Reading large request body using ngx_http_read_client_request_body

Maxim Dounin May 20, 2019 03:42PM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 20, 2019 04:35PM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 21, 2019 12:28AM

Re: Reading large request body using ngx_http_read_client_request_body

Patrick May 21, 2019 12:48AM

Re: Reading large request body using ngx_http_read_client_request_body

Maxim Dounin May 21, 2019 08:52AM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 21, 2019 12:53PM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 24, 2019 05:15PM

Re: Reading large request body using ngx_http_read_client_request_body

Maxim Dounin May 27, 2019 09:30AM

Re: Reading large request body using ngx_http_read_client_request_body

NginxNewbee May 28, 2019 06:19PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 303
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready