mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix HTTP-FLV and VOD-FLV conflicting bug.
This commit is contained in:
parent
d9842b0371
commit
2df1dcb05a
4 changed files with 33 additions and 0 deletions
|
@ -1050,6 +1050,18 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
|
|||
}
|
||||
}
|
||||
|
||||
// For HTTP-FLV stream, the template must have the same schema with upath.
|
||||
// The template is defined in config, the mout of http stream. The upath is specified by http request path.
|
||||
// If template is "[vhost]/[app]/[stream].flv", the upath should be:
|
||||
// matched for "/live/livestream.flv"
|
||||
// matched for "ossrs.net/live/livestream.flv"
|
||||
// not-matched for "/livestream.flv", which is actually "/__defaultApp__/livestream.flv", HTTP not support default app.
|
||||
// not-matched for "/live/show/livestream.flv"
|
||||
string upath = request->path();
|
||||
if (srs_string_count(upath, "/") != srs_string_count(entry->mount, "/")) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// convert to concreate class.
|
||||
SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(request);
|
||||
srs_assert(hreq);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
@ -451,6 +452,16 @@ bool srs_string_contains(string str, string flag0, string flag1, string flag2)
|
|||
return str.find(flag0) != string::npos || str.find(flag1) != string::npos || str.find(flag2) != string::npos;
|
||||
}
|
||||
|
||||
int srs_string_count(string str, string flag)
|
||||
{
|
||||
int nn = 0;
|
||||
for (int i = 0; i < (int)flag.length(); i++) {
|
||||
char ch = flag.at(i);
|
||||
nn += std::count(str.begin(), str.end(), ch);
|
||||
}
|
||||
return nn;
|
||||
}
|
||||
|
||||
vector<string> srs_string_split(string str, string flag)
|
||||
{
|
||||
vector<string> arr;
|
||||
|
|
|
@ -98,6 +98,8 @@ extern bool srs_string_starts_with(std::string str, std::string flag0, std::stri
|
|||
extern bool srs_string_contains(std::string str, std::string flag);
|
||||
extern bool srs_string_contains(std::string str, std::string flag0, std::string flag1);
|
||||
extern bool srs_string_contains(std::string str, std::string flag0, std::string flag1, std::string flag2);
|
||||
// Count each char of flag in string
|
||||
extern int srs_string_count(std::string str, std::string flag);
|
||||
// Find the min match in str for flags.
|
||||
extern std::string srs_string_min_match(std::string str, std::vector<std::string> flags);
|
||||
// Split the string by flag to array.
|
||||
|
|
|
@ -2319,6 +2319,14 @@ VOID TEST(KernelUtility, StringUtils)
|
|||
EXPECT_TRUE(srs_string_contains("srs", "s", "sr", "srs"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_EQ(0, srs_string_count("srs", "y"));
|
||||
EXPECT_EQ(0, srs_string_count("srs", ""));
|
||||
EXPECT_EQ(1, srs_string_count("srs", "r"));
|
||||
EXPECT_EQ(2, srs_string_count("srs", "s"));
|
||||
EXPECT_EQ(3, srs_string_count("srs", "sr"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
vector<string> flags;
|
||||
EXPECT_TRUE("srs" == srs_string_min_match("srs", flags));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue