@@ -1161,7 +1161,7 @@ r%5B%5D=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fjquery%2F1.7.2%2Fj
11611161GET /main
11621162--- response_body
11631163status: 500
1164- body:
1164+ body:
11651165
11661166
11671167
@@ -1182,7 +1182,7 @@ body:
11821182GET /main
11831183--- response_body
11841184status: 500
1185- body:
1185+ body:
11861186
11871187
11881188
@@ -1487,7 +1487,7 @@ post subreq: rc=0, status=200
14871487
14881488--- response_body
14891489status: 200
1490- body:
1490+ body:
14911491truncated: true
14921492
14931493--- error_log
@@ -1609,7 +1609,7 @@ post subreq: rc=0, status=200
16091609
16101610--- response_body
16111611status: 200
1612- body:
1612+ body:
16131613truncated: true
16141614
16151615--- error_log
@@ -2082,7 +2082,7 @@ post subreq: rc=0, status=200
20822082
20832083--- response_body
20842084status: 200
2085- body:
2085+ body:
20862086truncated: true
20872087
20882088--- error_log
@@ -3000,6 +3000,8 @@ method: GET, uri: /foo, X: GET /bar HTTP/1.0
300030000
30013001--- no_error_log
30023002[error]
3003+ --- skip_nginx
3004+ 3: >= 1.21.1
30033005
30043006
30053007
@@ -3128,6 +3130,8 @@ method: POST, uri: /foo
312831300
31293131--- no_error_log
31303132[error]
3133+ --- skip_nginx
3134+ 3: >= 1.21.1
31313135
31323136
31333137
@@ -3259,6 +3263,8 @@ method: POST, uri: /foo
325932630
32603264--- no_error_log
32613265[error]
3266+ --- skip_nginx
3267+ 3: >= 1.21.1
32623268
32633269
32643270
@@ -3391,6 +3397,8 @@ method: POST, uri: /foo
339133970
33923398--- no_error_log
33933399[error]
3400+ --- skip_nginx
3401+ 3: >= 1.21.1
33943402
33953403
33963404
@@ -3410,3 +3418,107 @@ GET /lua
34103418--- error_code: 500
34113419--- error_log
34123420unsupported HTTP method: 10240
3421+
3422+
3423+
3424+ === TEST 82: bad requests with both Content-Length and Transfer-Encoding (nginx >= 1.21.1)
3425+ --- http_config
3426+ upstream backend {
3427+ server unix:$TEST_NGINX_HTML_DIR/nginx.sock;
3428+ keepalive 32;
3429+ }
3430+
3431+ server {
3432+ listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
3433+
3434+ location / {
3435+ content_by_lua_block {
3436+ ngx.say("method: ", ngx.var.request_method,
3437+ ", uri: ", ngx.var.uri,
3438+ ", X: ", ngx.var.http_x)
3439+ }
3440+ }
3441+ }
3442+ --- config
3443+ location /proxy {
3444+ proxy_http_version 1.1;
3445+ proxy_set_header Connection "";
3446+ proxy_pass http://backend/foo;
3447+ }
3448+
3449+ location /capture {
3450+ server_tokens off;
3451+ more_clear_headers Date;
3452+
3453+ content_by_lua_block {
3454+ local res = ngx.location.capture("/proxy")
3455+ ngx.print(res.body)
3456+ }
3457+ }
3458+
3459+ location /t {
3460+ content_by_lua_block {
3461+ local req = [[
3462+ GET /capture HTTP/1.1
3463+ Host: test.com
3464+ Content-Length: 37
3465+ Transfer-Encoding: chunked
3466+
3467+ 0
3468+
3469+ GET /capture HTTP/1.1
3470+ Host: test.com
3471+ X: GET /bar HTTP/1.0
3472+
3473+ ]]
3474+
3475+ local sock = ngx.socket.tcp()
3476+ sock:settimeout(1000)
3477+
3478+ local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_SERVER_PORT)
3479+ if not ok then
3480+ ngx.say("failed to connect: ", err)
3481+ return
3482+ end
3483+
3484+ local bytes, err = sock:send(req)
3485+ if not bytes then
3486+ ngx.say("failed to send req: ", err)
3487+ return
3488+ end
3489+
3490+ ngx.say("req bytes: ", bytes)
3491+
3492+ local n_resp = 0
3493+
3494+ local reader = sock:receiveuntil("\r\n")
3495+ while true do
3496+ local line, err = reader()
3497+ if line then
3498+ ngx.say(line)
3499+ if line == "0" then
3500+ n_resp = n_resp + 1
3501+ end
3502+
3503+ if n_resp >= 2 then
3504+ break
3505+ end
3506+
3507+ else
3508+ ngx.say("err: ", err)
3509+ break
3510+ end
3511+ end
3512+
3513+ sock:close()
3514+ }
3515+ }
3516+ --- request
3517+ GET /t
3518+ --- response_body_like
3519+ req bytes: 146
3520+ HTTP/1.1 400 Bad Request
3521+ --- no_error_log
3522+ [error]
3523+ --- skip_nginx
3524+ 3: < 1.21.1
0 commit comments