Skip to content

Commit 7e4bd36

Browse files
committed
about nginx-clojure#49 optimization : add client_body_done checking in content
handler
1 parent 89b9786 commit 7e4bd36

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/c/ngx_http_clojure_module.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -736,18 +736,20 @@ static ngx_int_t ngx_http_clojure_handler(ngx_http_request_t * r) {
736736
}
737737

738738
if (lcf->always_read_body || (r->method & (NGX_HTTP_POST | NGX_HTTP_PUT | NGX_HTTP_PATCH))) {
739-
r->request_body_in_single_buf = 1;
740-
r->request_body_in_clean_file = 1;
741-
r->request_body_in_persistent_file = 1;
742-
743-
rc = ngx_http_read_client_request_body(r, ngx_http_clojure_client_body_handler);
744-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
745-
return rc;
746-
}
747-
748-
if (rc == NGX_AGAIN) {
749-
ctx->async_body_read = 1;
750-
return NGX_DONE;
739+
if (!ctx->client_body_done) {/*maybe done by rewrite handler*/
740+
r->request_body_in_single_buf = 1;
741+
r->request_body_in_clean_file = 1;
742+
r->request_body_in_persistent_file = 1;
743+
744+
rc = ngx_http_read_client_request_body(r, ngx_http_clojure_client_body_handler);
745+
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
746+
return rc;
747+
}
748+
749+
if (rc == NGX_AGAIN) {
750+
ctx->async_body_read = 1;
751+
return NGX_DONE;
752+
}
751753
}
752754
}else {
753755
rc = ngx_http_discard_request_body(r);

0 commit comments

Comments
 (0)