mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
support more splash in http url. remove the strip of SrsRequest, use srs_string_remove instead, change to 0.9.44
This commit is contained in:
parent
f2216691f9
commit
b71eb0d49a
8 changed files with 77 additions and 42 deletions
|
@ -27,7 +27,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
std::string srs_replace(std::string str, std::string old_str, std::string new_str)
|
||||
using namespace std;
|
||||
|
||||
string srs_string_replace(string str, string old_str, string new_str)
|
||||
{
|
||||
std::string ret = str;
|
||||
|
||||
|
@ -38,13 +40,52 @@ std::string srs_replace(std::string str, std::string old_str, std::string new_st
|
|||
size_t pos = 0;
|
||||
while ((pos = ret.find(old_str, pos)) != std::string::npos) {
|
||||
ret = ret.replace(pos, old_str.length(), new_str);
|
||||
pos += new_str.length();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string srs_dns_resolve(std::string host)
|
||||
string srs_string_trim_end(string str, string trim_chars)
|
||||
{
|
||||
std::string ret = str;
|
||||
|
||||
for (int i = 0; i < (int)trim_chars.length(); i++) {
|
||||
char ch = trim_chars.at(i);
|
||||
|
||||
while (!ret.empty() && ret.at(ret.length() - 1) == ch) {
|
||||
ret.erase(ret.end() - 1);
|
||||
|
||||
// ok, matched, should reset the search
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
string srs_string_remove(string str, string remove_chars)
|
||||
{
|
||||
std::string ret = str;
|
||||
|
||||
for (int i = 0; i < (int)remove_chars.length(); i++) {
|
||||
char ch = remove_chars.at(i);
|
||||
|
||||
for (std::string::iterator it = ret.begin(); it != ret.end();) {
|
||||
if (ch == *it) {
|
||||
it = ret.erase(it);
|
||||
|
||||
// ok, matched, should reset the search
|
||||
i = 0;
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
string srs_dns_resolve(string host)
|
||||
{
|
||||
if (inet_addr(host.c_str()) != INADDR_NONE) {
|
||||
return host;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue