From 2d88115b3f67fa5bf53184aed155fe8e0d58fe75 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 12 Mar 2022 10:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84http=E7=9B=B4=E6=92=ADurl?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E8=A7=84=E5=88=99pr:#1467?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index b52be041..c044f205 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -185,20 +185,21 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffi // unsupported schema return false; } - } - else { - int prefix_len = url_suffix.length(); - if(url.length() < prefix_len || strcasecmp(url.substr(url.length() - prefix_len).c_str(), url_suffix.c_str())) { + } else { + int prefix_size = url_suffix.size(); + if (url.size() < prefix_size || strcasecmp(url.data() + (url.size() - prefix_size), url_suffix.data())) { //未找到后缀 return false; } - //url去除特殊后缀 - url = url.substr(0, url.size() - prefix_len); + // url去除特殊后缀 + url.resize(url.size() - prefix_size); } //带参数的url - if(!_parser.Params().empty()) - url += "?" + _parser.Params(); + if (!_parser.Params().empty()) { + url += "?"; + url += _parser.Params(); + } //解析带上协议+参数完整的url _mediaInfo.parse(schema + "://" + _parser["Host"] + url); @@ -235,8 +236,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffi if (!src) { //未找到该流 strong_self->sendNotFound(close_flag); - } - else { + } else { strong_self->_is_live_stream = true; //触发回调 cb(src);