1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 20:31:56 +00:00

Improve test coverage for HTTP header.

This commit is contained in:
winlin 2019-12-16 12:11:29 +08:00
parent 8c10c26f00
commit 0886acbdb7

View file

@ -128,3 +128,28 @@ VOID TEST(ProtocolHTTPTest, ResponseHTTPError)
EXPECT_STREQ(mock_http_response(302,"Found").c_str(), HELPER_BUFFER2STR(&w.io.out_buffer).c_str());
}
}
VOID TEST(ProtocolHTTPTest, HTTPHeader)
{
SrsHttpHeader h;
h.set("Server", "SRS");
EXPECT_STREQ("SRS", h.get("Server").c_str());
stringstream ss;
h.write(ss);
EXPECT_STREQ("Server: SRS\r\n", ss.str().c_str());
h.del("Server");
EXPECT_TRUE(h.get("Server").empty());
EXPECT_EQ(-1, h.content_length());
h.set_content_length(0);
EXPECT_EQ(0, h.content_length());
h.set_content_length(1024);
EXPECT_EQ(1024, h.content_length());
h.set_content_type("text/plain");
EXPECT_STREQ("text/plain", h.content_type().c_str());
}