mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Improve test coverage for http message
This commit is contained in:
parent
43a5cea158
commit
6c50d85671
3 changed files with 39 additions and 0 deletions
|
@ -460,6 +460,11 @@ string SrsHttpMessage::host()
|
||||||
return _uri->get_host();
|
return _uri->get_host();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsHttpMessage::port()
|
||||||
|
{
|
||||||
|
return _uri->get_port();
|
||||||
|
}
|
||||||
|
|
||||||
string SrsHttpMessage::path()
|
string SrsHttpMessage::path()
|
||||||
{
|
{
|
||||||
return _uri->get_path();
|
return _uri->get_path();
|
||||||
|
|
|
@ -163,6 +163,7 @@ public:
|
||||||
// The url maybe the path.
|
// The url maybe the path.
|
||||||
virtual std::string url();
|
virtual std::string url();
|
||||||
virtual std::string host();
|
virtual std::string host();
|
||||||
|
virtual int port();
|
||||||
virtual std::string path();
|
virtual std::string path();
|
||||||
virtual std::string query();
|
virtual std::string query();
|
||||||
virtual std::string ext();
|
virtual std::string ext();
|
||||||
|
|
|
@ -1265,6 +1265,39 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
|
||||||
|
|
||||||
VOID TEST(ProtocolHTTPTest, HTTPMessageUpdate)
|
VOID TEST(ProtocolHTTPTest, HTTPMessageUpdate)
|
||||||
{
|
{
|
||||||
|
// Port use 80 if error.
|
||||||
|
if (true) {
|
||||||
|
SrsHttpHeader h;
|
||||||
|
h.set("Host", "ossrs.net:-1");
|
||||||
|
|
||||||
|
SrsHttpMessage m;
|
||||||
|
m.set_header(&h, false);
|
||||||
|
m.set_url("/api/v1", false);
|
||||||
|
EXPECT_EQ(80, m.port());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Port default to 80.
|
||||||
|
if (true) {
|
||||||
|
SrsHttpHeader h;
|
||||||
|
h.set("Host", "ossrs.net");
|
||||||
|
|
||||||
|
SrsHttpMessage m;
|
||||||
|
m.set_header(&h, false);
|
||||||
|
m.set_url("/api/v1", false);
|
||||||
|
EXPECT_EQ(80, m.port());
|
||||||
|
}
|
||||||
|
|
||||||
|
// For port not 80.
|
||||||
|
if (true) {
|
||||||
|
SrsHttpHeader h;
|
||||||
|
h.set("Host", "ossrs.net:8080");
|
||||||
|
|
||||||
|
SrsHttpMessage m;
|
||||||
|
m.set_header(&h, false);
|
||||||
|
m.set_url("/api/v1", false);
|
||||||
|
EXPECT_EQ(8080, m.port());
|
||||||
|
}
|
||||||
|
|
||||||
// The host is overwrite by header.
|
// The host is overwrite by header.
|
||||||
if (true) {
|
if (true) {
|
||||||
SrsHttpHeader h;
|
SrsHttpHeader h;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue