Skip to content

Commit

Permalink
Fix #1255, support vhost/domain in query string for HTTP streaming. 3…
Browse files Browse the repository at this point in the history
….0.90
  • Loading branch information
winlinvip committed Dec 29, 2019
1 parent 8a28a11 commit eb8e7ad
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <srs_auto_headers.hpp>
Expand Down
10 changes: 10 additions & 0 deletions trunk/src/service/srs_service_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,16 @@ string SrsHttpMessage::url()

string SrsHttpMessage::host()
{
std::map<string, string>::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();
}

Expand Down
6 changes: 3 additions & 3 deletions trunk/src/utest/srs_utest_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
61 changes: 61 additions & 0 deletions trunk/src/utest/srs_utest_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit eb8e7ad

Please sign in to comment.