diff options
author | Semir Sionek <ssionek@cisco.com> | 2025-01-17 10:06:23 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2025-01-23 18:30:28 +0000 |
commit | 5e94895dfd7d597a88965e6b5c1d2a3bc6ffe67e (patch) | |
tree | 488c998e057296d7fecefb11c1756289e58f34d5 /extras | |
parent | 7267149267fae4bb814af441fabb42767c1a720d (diff) |
http_static: introduce max-body-size parameter
Introduce the max-body-size parameter to put a limit on how big of a
POST request can the static server take (and how big of a memory
allocation that causes).
Type: improvement
Change-Id: I93cdeaf38dabe2850665e92bedbaa0545c375214
Signed-off-by: Semir Sionek <ssionek@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/hs-test/http_test.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 4cbcdeb1b21..68934550b69 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -36,7 +36,7 @@ func init() { HttpClientErrRespTest, HttpClientPostFormTest, HttpClientGet128kbResponseTest, HttpClientGetResponseBodyTest, HttpClientGetNoResponseBodyTest, HttpClientPostFileTest, HttpClientPostFilePtrTest, HttpUnitTest, HttpRequestLineTest, HttpClientGetTimeout, HttpStaticFileHandlerWrkTest, HttpStaticUrlHandlerWrkTest, HttpConnTimeoutTest, - HttpClientGetRepeat, HttpClientPostRepeat, HttpIgnoreH2UpgradeTest, HttpInvalidAuthorityFormUriTest) + HttpClientGetRepeat, HttpClientPostRepeat, HttpIgnoreH2UpgradeTest, HttpInvalidAuthorityFormUriTest, HttpHeaderErrorConnectionDropTest) RegisterNoTopoSoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest, PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest, PromConsecutiveConnectionsTest, HttpGetTpsTlsTest, HttpPostTpsTlsTest) @@ -1240,7 +1240,7 @@ func HttpInvalidContentLengthTest(s *NoTopoSuite) { func HttpContentLengthTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug max-body-size 12")) ifName := s.VppIfName() resp, err := TcpSendReceive(serverAddress+":80", @@ -1259,6 +1259,25 @@ func HttpContentLengthTest(s *NoTopoSuite) { validatePostInterfaceStats(s, resp) } +func HttpHeaderErrorConnectionDropTest(s *NoTopoSuite) { + vpp := s.Containers.Vpp.VppInstance + serverAddress := s.VppAddr() + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug max-body-size 12")) + request := "POST /interface_stats.json HTTP/1.1\r\nContent-Length: 18234234\r\n\r\n" + s.VppIfName() + conn, err := net.DialTimeout("tcp", serverAddress+":80", time.Second*30) + s.AssertNil(err, fmt.Sprint(err)) + err = conn.SetDeadline(time.Now().Add(time.Second * 10)) + s.AssertNil(err, fmt.Sprint(err)) + _, err = conn.Write([]byte(request)) + s.AssertNil(err, fmt.Sprint(err)) + reply := make([]byte, 1024) + _, err = conn.Read(reply) + s.AssertNil(err, fmt.Sprint(err)) + s.AssertContains(string(reply), "HTTP/1.1 413 Content Too Large") + check := make([]byte, 1) + _, err = conn.Read(check) + s.AssertEqual(err, io.EOF) +} func HttpMethodNotImplementedTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() |