From 0d5ef99724d27d182af8a133485872efed896b03 Mon Sep 17 00:00:00 2001 From: alexliyu7352 Date: Fri, 17 Dec 2021 17:48:05 +0800 Subject: [PATCH] =?UTF-8?q?http=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=AE=80=E5=8D=95=E9=AA=8C=E8=AF=81=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=20(#1289)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 加速track的准备速度 * 重命名为isAllTrackReady * 无须缓冲帧时,暂不用转换为可缓存帧 * 支持简单验证协议 * 优化代码 Co-authored-by: 夏楚 <771730766@qq.com> --- src/Http/HttpClient.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index e3062a24..74a8f71f 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -9,6 +9,7 @@ */ #include +#include "Util/base64.h" #include "HttpClient.h" #include "Common/config.h" @@ -39,6 +40,13 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) { if (_path.empty()) { _path = "/"; } + auto pos = host.find('@'); + if (pos != string::npos) { + //去除?后面的字符串 + auto authStr = host.substr(0, pos); + host = host.substr(pos + 1, host.size()); + _header.emplace("Authorization", "Basic " + encodeBase64(authStr)); + } auto host_header = host; uint16_t port = atoi(FindField(host.data(), ":", NULL).data()); if (port <= 0) { @@ -322,4 +330,4 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) { } } -} /* namespace mediakit */ \ No newline at end of file +} /* namespace mediakit */