mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix ParseHttpMessage failing to store >2 repeatable headers (#657)
This commit is contained in:
parent
e557058ac8
commit
84b9b8ed87
2 changed files with 31 additions and 4 deletions
|
@ -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\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue