|
| 1 | +''' |
| 2 | +''' |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | + |
| 19 | +Test.Summary = ''' |
| 20 | +Make sure we have a valid buffer to write on. This used to make ats crash. |
| 21 | +''' |
| 22 | +Test.ContinueOnFail = True |
| 23 | + |
| 24 | +# Use microserver instead of httpbin |
| 25 | +server = Test.MakeOriginServer("server") |
| 26 | + |
| 27 | +# Add a simple response for POST |
| 28 | +request_header = {"headers": "POST /post HTTP/1.1\r\nHost: *\r\n\r\n", "timestamp": "1469733493.993", "body": ""} |
| 29 | +response_header = { |
| 30 | + "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 2\r\n\r\n", |
| 31 | + "timestamp": "1469733493.993", |
| 32 | + "body": "OK" |
| 33 | +} |
| 34 | +server.addResponse("sessionfile.log", request_header, response_header) |
| 35 | + |
| 36 | +ts = Test.MakeATSProcess("ts") |
| 37 | + |
| 38 | +ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.Port)) |
| 39 | + |
| 40 | +ts.Disk.records_config.update( |
| 41 | + { |
| 42 | + 'proxy.config.diags.debug.enabled': 1, |
| 43 | + 'proxy.config.diags.debug.tags': 'http', |
| 44 | + 'proxy.config.http.request_buffer_enabled': 1, |
| 45 | + 'proxy.config.http.number_of_redirections': 1, |
| 46 | + }) |
| 47 | + |
| 48 | +test_run = Test.AddTestRun("post buffer test") |
| 49 | +test_run.Processes.Default.StartBefore(server) |
| 50 | +test_run.Processes.Default.StartBefore(ts) |
| 51 | +test_run.Processes.Default.Command = f'curl -v -H "Expect: 100-continue" -d "abc" http://127.0.0.1:{ts.Variables.port}/post' |
| 52 | +test_run.Processes.Default.ReturnCode = 0 |
| 53 | +test_run.StillRunningAfter = server |
| 54 | +test_run.StillRunningAfter = ts # TS should not crash |
| 55 | + |
| 56 | +# Verify request with Expect header was processed |
| 57 | +ts.Disk.traffic_out.Content += Testers.ContainsExpression("100-continue", "Has Expect header") |
| 58 | +# Verify ATS handled the POST request (no crash) |
| 59 | +ts.Disk.traffic_out.Content += Testers.ContainsExpression("client post", "POST tunnel started") |
0 commit comments