diff --git a/README.md b/README.md index 5894a7bf5..40d3147c4 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-29, For [#1255][bug #1255], support vhost/domain in query string for HTTP streaming. 3.0.90 * v3.0, 2019-12-29, For [#299][bug #299], increase dash segment size for avsync issue. 3.0.89 * v3.0, 2019-12-27, For [#299][bug #299], fix some bugs in dash, it works now. 3.0.88 * v3.0, 2019-12-27, For [#1544][bug #1544], fix memory leaking for complex error. 3.0.87 @@ -1573,6 +1574,7 @@ Winlin [bug #1282]: https://github.com/ossrs/srs/issues/1282 [bug #1105]: https://github.com/ossrs/srs/issues/1105 [bug #1544]: https://github.com/ossrs/srs/issues/1544 +[bug #1255]: https://github.com/ossrs/srs/issues/1255 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 3b5a37f0f..366f57efb 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 89 +#define VERSION_REVISION 90 // The macros generated by configure script. #include diff --git a/trunk/src/service/srs_service_http_conn.cpp b/trunk/src/service/srs_service_http_conn.cpp index 2d0cb3ba2..ebdd42952 100644 --- a/trunk/src/service/srs_service_http_conn.cpp +++ b/trunk/src/service/srs_service_http_conn.cpp @@ -491,6 +491,16 @@ string SrsHttpMessage::url() string SrsHttpMessage::host() { + std::map::iterator it = _query.find("vhost"); + if (it != _query.end() && !it->second.empty()) { + return it->second; + } + + it = _query.find("domain"); + if (it != _query.end() && !it->second.empty()) { + return it->second; + } + return _uri->get_host(); } diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 4f40459fe..471982e9d 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -1820,9 +1820,9 @@ VOID TEST(ConfigUnitTest, CheckDefaultValuesVhost) if (true) { EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF)); - EXPECT_EQ(3 * SRS_UTIME_SECONDS, conf.get_dash_fragment("")); - EXPECT_EQ(30 * SRS_UTIME_SECONDS, conf.get_dash_update_period("")); - EXPECT_EQ(60 * SRS_UTIME_SECONDS, conf.get_dash_timeshift("")); + EXPECT_EQ(30 * SRS_UTIME_SECONDS, conf.get_dash_fragment("")); + EXPECT_EQ(150 * SRS_UTIME_SECONDS, conf.get_dash_update_period("")); + EXPECT_EQ(300 * SRS_UTIME_SECONDS, conf.get_dash_timeshift("")); EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{dash{dash_fragment 4;dash_update_period 40;dash_timeshift 70;}}")); EXPECT_EQ(4 * SRS_UTIME_SECONDS, conf.get_dash_fragment("v")); diff --git a/trunk/src/utest/srs_utest_http.cpp b/trunk/src/utest/srs_utest_http.cpp index fdff6743e..db7e566d1 100644 --- a/trunk/src/utest/srs_utest_http.cpp +++ b/trunk/src/utest/srs_utest_http.cpp @@ -1550,10 +1550,71 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser) } } +VOID TEST(ProtocolHTTPTest, VhostInQuery) +{ + srs_error_t err; + + if (true) { + SrsHttpHeader h; + + SrsHttpMessage m; + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1?vhost=rt.ossrs.net&token=xxx", false)); + m.set_header(&h, false); + EXPECT_STREQ("rt.ossrs.net", m.host().c_str()); + } + + if (true) { + SrsHttpHeader h; + + SrsHttpMessage m; + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1?vhost=rt.ossrs.net&&token=xxx", false)); + m.set_header(&h, false); + EXPECT_STREQ("rt.ossrs.net", m.host().c_str()); + } + + if (true) { + SrsHttpHeader h; + h.set("Host", "ossrs.net:-1"); + + SrsHttpMessage m; + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1?vhost=rt.ossrs.net", false)); + m.set_header(&h, false); + EXPECT_STREQ("rt.ossrs.net", m.host().c_str()); + } + + if (true) { + SrsHttpHeader h; + + SrsHttpMessage m; + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1?vhost=ossrs.net", false)); + m.set_header(&h, false); + EXPECT_STREQ("ossrs.net", m.host().c_str()); + } + + if (true) { + SrsHttpHeader h; + h.set("Host", "ossrs.net"); + + SrsHttpMessage m; + m.set_header(&h, false); + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1", false)); + EXPECT_STREQ("ossrs.net", m.host().c_str()); + } +} + VOID TEST(ProtocolHTTPTest, HTTPMessageUpdate) { srs_error_t err; + if (true) { + SrsHttpHeader h; + + SrsHttpMessage m; + HELPER_ASSERT_SUCCESS(m.set_url("/api/v1?vhost=ossrs.net", false)); + m.set_header(&h, false); + EXPECT_STRNE("ossrs.net", m.host().c_str()); + } + if (true) { SrsHttpHeader h; h.set("Host", "ossrs.net:-1");