1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

use system utility for string finds

This commit is contained in:
winlin 2015-10-13 16:06:37 +08:00
parent ca73534d7e
commit d9f991ed2f
16 changed files with 111 additions and 112 deletions

View file

@ -572,12 +572,7 @@ int SrsHttpMessage::update(string url, bool allow_jsonp, http_parser* header, Sr
}
// parse ext.
_ext = _uri->get_path();
if ((pos = _ext.rfind(".")) != string::npos) {
_ext = _ext.substr(pos);
} else {
_ext = "";
}
_ext = srs_path_filext(_uri->get_path());
// parse jsonp request message.
if (allow_jsonp) {
@ -816,23 +811,23 @@ SrsRequest* SrsHttpMessage::to_request(string vhost)
{
SrsRequest* req = new SrsRequest();
req->app = _uri->get_path();
size_t pos = string::npos;
if ((pos = req->app.rfind("/")) != string::npos) {
req->stream = req->app.substr(pos + 1);
req->app = req->app.substr(0, pos);
}
if ((pos = req->stream.rfind(".")) != string::npos) {
req->stream = req->stream.substr(0, pos);
}
// http path, for instance, /live/livestream.flv, parse to
// app: /live
// stream: livestream.flv
srs_parse_rtmp_url(_uri->get_path(), req->app, req->stream);
req->tcUrl = "rtmp://" + vhost + req->app;
// trim the start slash, for instance, /live to live
req->app = srs_string_trim_start(req->app, "/");
// remove the extension, for instance, livestream.flv to livestream
req->stream = srs_path_filename(req->stream);
// generate others.
req->tcUrl = "rtmp://" + vhost + "/" + req->app;
req->pageUrl = get_request_header("Referer");
req->objectEncoding = 0;
srs_discovery_tc_url(req->tcUrl,
req->schema, req->host, req->vhost, req->app, req->port,
req->param);
srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->port, req->param);
req->strip();
return req;