|
|
|
@ -5814,7 +5814,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 75, nparsed = 75, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(75, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_TRUE(parser.body && 5 == parser.body->length);
|
|
|
|
|
EXPECT_TRUE(parser.headers_complete);
|
|
|
|
|
EXPECT_TRUE(parser.message_complete);
|
|
|
|
@ -5825,7 +5825,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 150, nparsed = 150, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHelloGET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nWorld"));
|
|
|
|
|
EXPECT_EQ(150, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5833,13 +5833,13 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 70, nparsed = 70, nread = 0, content_length = 5, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\n"));
|
|
|
|
|
EXPECT_EQ(70, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(5, parser.parser->content_length);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(5, (int)parser.parser->content_length);
|
|
|
|
|
|
|
|
|
|
// size = 79, nparsed = 5, nread = 1, content_length = -1, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_FAILED(parser.parse("elloGET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(5, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(1, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(1, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(-1, (int64_t)parser.parser->content_length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -5848,13 +5848,13 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 70, nparsed = 70, nread = 0, content_length = 5, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\n"));
|
|
|
|
|
EXPECT_EQ(70, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(5, parser.parser->content_length);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(5, (int)parser.parser->content_length);
|
|
|
|
|
|
|
|
|
|
// size = 80, nparsed = 70, nread = 0, content_length = 0, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("HelloGET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nWorld"));
|
|
|
|
|
EXPECT_EQ(80, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->content_length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -5863,7 +5863,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 73, nparsed = 73, nread = 0, content_length = 2, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHel"));
|
|
|
|
|
EXPECT_EQ(73, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(2, parser.parser->content_length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -5872,7 +5872,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 82, nparsed = 75, nread = 1, content_length = -1, Header("Content-Length", 5)
|
|
|
|
|
HELPER_EXPECT_FAILED(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHello World!"));
|
|
|
|
|
EXPECT_EQ(75, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(1, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(1, (int)parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(-1, (int64_t)parser.parser->content_length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -5886,7 +5886,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 41, nparsed = 41, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("st: ossrs.net\r\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(41, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5899,7 +5899,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 34, nparsed = 34, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("rs.net\r\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(34, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5912,7 +5912,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 27, nparsed = 27, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(27, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5925,7 +5925,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 7, nparsed = 7, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("\r\nHello"));
|
|
|
|
|
EXPECT_EQ(7, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5938,7 +5938,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 6, nparsed = 6, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("\nHello"));
|
|
|
|
|
EXPECT_EQ(6, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
@ -5946,7 +5946,7 @@ VOID TEST(ProtocolHTTPTest, HTTPParser)
|
|
|
|
|
// size = 75, nparsed = 75, nread = 0
|
|
|
|
|
HELPER_EXPECT_SUCCESS(parser.parse("GET /gslb/v1/versions HTTP/1.1\r\nHost: ossrs.net\r\nContent-Length: 5\r\n\r\nHello"));
|
|
|
|
|
EXPECT_EQ(75, (int)parser.parsed);
|
|
|
|
|
EXPECT_EQ(0, parser.parser->nread);
|
|
|
|
|
EXPECT_EQ(0, (int)parser.parser->nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|