Commit ee13ca57 by xiongziliang

Merge branch 'master' of github.com:ZLMediaKit/ZLMediaKit

parents 0feac7c9 0d5ef997
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
*/ */
#include <cstdlib> #include <cstdlib>
#include "Util/base64.h"
#include "HttpClient.h" #include "HttpClient.h"
#include "Common/config.h" #include "Common/config.h"
...@@ -39,6 +40,13 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) { ...@@ -39,6 +40,13 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) {
if (_path.empty()) { if (_path.empty()) {
_path = "/"; _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; auto host_header = host;
uint16_t port = atoi(FindField(host.data(), ":", NULL).data()); uint16_t port = atoi(FindField(host.data(), ":", NULL).data());
if (port <= 0) { if (port <= 0) {
...@@ -322,4 +330,4 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) { ...@@ -322,4 +330,4 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
} }
} }
} /* namespace mediakit */ } /* namespace mediakit */
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论