Skip to content

Commit efada79

Browse files
authored
Add autest for empty POST framing: 411 response (#13055)
Add a replay-based autest for a POST request that omits both Content-Length and Transfer-Encoding. This captures the current 411 response in ATS and gives us a focused reproducer for issue 12960. 411 is in compliance with the RFC: https://datatracker.ietf.org/doc/html/rfc9112#section-6.3 A server MAY reject a request that contains a message body but not a Content-Length by responding with 411 (Length Required). Fixes: #12960
1 parent c478245 commit efada79

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
Verify that POST requests without a body are accepted.
3+
'''
4+
# Licensed to the Apache Software Foundation (ASF) under one
5+
# or more contributor license agreements. See the NOTICE file
6+
# distributed with this work for additional information
7+
# regarding copyright ownership. The ASF licenses this file
8+
# to you under the Apache License, Version 2.0 (the
9+
# "License"); you may not use this file except in compliance
10+
# with the License. You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
20+
Test.Summary = '''
21+
Verify that POST request without a Content-Length or Transfer-Encoding header is
22+
rejected with a 411.
23+
'''
24+
25+
Test.ATSReplayTest(replay_file='replay/post-no-cl.replay.yaml')
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
meta:
18+
version: "1.0"
19+
20+
autest:
21+
description: 'Verify ATS rejects unspecified length POST requests with a 411.'
22+
23+
dns:
24+
name: 'dns'
25+
26+
server:
27+
name: 'server'
28+
29+
client:
30+
name: 'client'
31+
32+
ats:
33+
name: 'ts'
34+
process_config:
35+
enable_cache: false
36+
37+
records_config:
38+
proxy.config.diags.debug.enabled: 1
39+
proxy.config.diags.debug.tags: 'http|http_trans'
40+
41+
remap_config:
42+
- from: "http://example.com/"
43+
to: "http://backend.example.com:{SERVER_HTTP_PORT}/"
44+
45+
sessions:
46+
- transactions:
47+
- client-request:
48+
method: "POST"
49+
version: "1.1"
50+
url: /no-cl
51+
headers:
52+
fields:
53+
- [ Host, example.com ]
54+
- [ uuid, post-no-cl ]
55+
56+
proxy-request:
57+
expect: absent
58+
59+
proxy-response:
60+
status: 411

0 commit comments

Comments
 (0)