Opened 7 years ago

Closed 7 years ago

#1439 closed defect (fixed)

auto_index module should discard request body explicitly

Reported by: Alex Zhang Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.13.x
Keywords: autoindex Cc:
uname -a: Linux Fedora26-64 4.13.15-200.fc26.x86_64 #1 SMP Tue Nov 21 21:10:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.13.8
built by gcc 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
configure arguments: --prefix=/home/alex/bin_install/nginx


Hi all!

I found that auto_index module doesn't call the ngx_http_discard_request_body to discard the request body, and when a GET request carries some data, the request body will be treated as a pipeline request, most of time it will emit another 400 BAD REQUEST response.

You can reproduce this problem with the following configuration:

server {
     listen 8082;
     server_name _;

     location / {
         autoindex on;
         root /tmp;

And send a request using curl.

curl -v -XGET -d "a"

We can see the error.log:

2017/11/30 17:04:06 [info] 19098#0: *2 client sent invalid method while reading client pipelined request line, client:, server: _, request: "a"

Or we can capture the 400 BAD REQUEST response with tcpdump.

After trying this patch, this problem is fixed.

diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index b3bf6528..ebb3cc41 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -276,6 +276,11 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
     r->headers_out.content_type_len = r->headers_out.content_type.len;
     r->headers_out.content_type_lowcase = NULL;

+    rc = ngx_http_discard_request_body(r);
+    if (rc != NGX_OK) {
+        return rc;
+    }
     rc = ngx_http_send_header(r);

     if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {

Change History (3)

comment:1 by Maxim Dounin, 7 years ago

Status: newaccepted

Thanks for reporting this.

comment:2 by Maxim Dounin <mdounin@…>, 7 years ago

In 7164:044cb349fd3c/nginx:

Autoindex: discard request body (ticket #1439).

comment:3 by Maxim Dounin, 7 years ago

Resolution: fixed
Status: acceptedclosed

Fix committed, thanks.

Note: See TracTickets for help on using tickets.