From f202fc2c171ef65f5c59b5481fe1b9db9872a43c Mon Sep 17 00:00:00 2001 From: Malcolm Seyd Date: Mon, 10 Oct 2022 18:17:59 -0700 Subject: [PATCH] add failing test case --- test/net/http/parsehttpmessage_test.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/net/http/parsehttpmessage_test.c b/test/net/http/parsehttpmessage_test.c index 4adbf900f..d46f0dcba 100644 --- a/test/net/http/parsehttpmessage_test.c +++ b/test/net/http/parsehttpmessage_test.c @@ -16,11 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" #include "libc/errno.h" +#include "libc/intrin/bits.h" #include "libc/log/check.h" -#include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" +#include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" @@ -245,6 +245,29 @@ Content-Type: text/plain\r\n\ ASSERT_EQ(0, req->xheaders.n); } +TEST(ParseHttpMessage, testCommaSeparatedOnMultipleLines_manyLines) { + static const char m[] = "\ +GET / HTTP/1.1\r\n\ +Accept: text/html\r\n\ +Accept: text/plain\r\n\ +Accept: text/csv\r\n\ +Accept: text/xml\r\n\ +Accept: text/css\r\n\ +\r\n"; + InitHttpMessage(req, kHttpRequest); + EXPECT_EQ(strlen(m), ParseHttpMessage(req, m, strlen(m))); + EXPECT_STREQ("text/html", gc(slice(m, req->headers[kHttpAccept]))); + ASSERT_EQ(4, req->xheaders.n); + EXPECT_STREQ("Accept", gc(slice(m, req->xheaders.p[0].k))); + EXPECT_STREQ("text/plain", gc(slice(m, req->xheaders.p[0].v))); + EXPECT_STREQ("Accept", gc(slice(m, req->xheaders.p[1].k))); + EXPECT_STREQ("text/csv", gc(slice(m, req->xheaders.p[1].v))); + EXPECT_STREQ("Accept", gc(slice(m, req->xheaders.p[2].k))); + EXPECT_STREQ("text/xml", gc(slice(m, req->xheaders.p[2].v))); + EXPECT_STREQ("Accept", gc(slice(m, req->xheaders.p[3].k))); + EXPECT_STREQ("text/css", gc(slice(m, req->xheaders.p[3].v))); +} + TEST(ParseHttpMessage, testCommaSeparatedOnMultipleLines_becomesLinear) { static const char m[] = "\ GET / HTTP/1.1\r\n\