@@ -1161,7 +1161,7 @@ r%5B%5D=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fjquery%2F1.7.2%2Fj
1161
1161
GET /main
1162
1162
--- response_body
1163
1163
status: 500
1164
- body:
1164
+ body:
1165
1165
1166
1166
1167
1167
@@ -1182,7 +1182,7 @@ body:
1182
1182
GET /main
1183
1183
--- response_body
1184
1184
status: 500
1185
- body:
1185
+ body:
1186
1186
1187
1187
1188
1188
@@ -1487,7 +1487,7 @@ post subreq: rc=0, status=200
1487
1487
1488
1488
--- response_body
1489
1489
status: 200
1490
- body:
1490
+ body:
1491
1491
truncated: true
1492
1492
1493
1493
--- error_log
@@ -1609,7 +1609,7 @@ post subreq: rc=0, status=200
1609
1609
1610
1610
--- response_body
1611
1611
status: 200
1612
- body:
1612
+ body:
1613
1613
truncated: true
1614
1614
1615
1615
--- error_log
@@ -2082,7 +2082,7 @@ post subreq: rc=0, status=200
2082
2082
2083
2083
--- response_body
2084
2084
status: 200
2085
- body:
2085
+ body:
2086
2086
truncated: true
2087
2087
2088
2088
--- error_log
@@ -3000,6 +3000,8 @@ method: GET, uri: /foo, X: GET /bar HTTP/1.0
3000
3000
0
3001
3001
--- no_error_log
3002
3002
[error]
3003
+ --- skip_nginx
3004
+ 3: >= 1.21.1
3003
3005
3004
3006
3005
3007
@@ -3128,6 +3130,8 @@ method: POST, uri: /foo
3128
3130
0
3129
3131
--- no_error_log
3130
3132
[error]
3133
+ --- skip_nginx
3134
+ 3: >= 1.21.1
3131
3135
3132
3136
3133
3137
@@ -3259,6 +3263,8 @@ method: POST, uri: /foo
3259
3263
0
3260
3264
--- no_error_log
3261
3265
[error]
3266
+ --- skip_nginx
3267
+ 3: >= 1.21.1
3262
3268
3263
3269
3264
3270
@@ -3391,6 +3397,8 @@ method: POST, uri: /foo
3391
3397
0
3392
3398
--- no_error_log
3393
3399
[error]
3400
+ --- skip_nginx
3401
+ 3: >= 1.21.1
3394
3402
3395
3403
3396
3404
@@ -3410,3 +3418,107 @@ GET /lua
3410
3418
--- error_code: 500
3411
3419
--- error_log
3412
3420
unsupported 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