mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
修复http客户端复用header无法更新的bug: #1349
This commit is contained in:
parent
60f11df1ea
commit
fdcc29e0ed
@ -41,6 +41,8 @@ void HttpClient::sendRequest(const string &url, float timeout_sec, float recv_ti
|
||||
if (_path.empty()) {
|
||||
_path = "/";
|
||||
}
|
||||
//重新设置header,防止上次请求的header干扰
|
||||
_header = _user_set_header;
|
||||
auto pos = host.find('@');
|
||||
if (pos != string::npos) {
|
||||
//去除?后面的字符串
|
||||
@ -94,6 +96,7 @@ void HttpClient::sendRequest(const string &url, float timeout_sec, float recv_ti
|
||||
void HttpClient::clear() {
|
||||
_url.clear();
|
||||
_header.clear();
|
||||
_user_set_header.clear();
|
||||
_body.reset();
|
||||
_method.clear();
|
||||
_path.clear();
|
||||
@ -116,14 +119,14 @@ void HttpClient::setMethod(string method) {
|
||||
}
|
||||
|
||||
void HttpClient::setHeader(HttpHeader header) {
|
||||
_header = std::move(header);
|
||||
_user_set_header = std::move(header);
|
||||
}
|
||||
|
||||
HttpClient &HttpClient::addHeader(string key, string val, bool force) {
|
||||
if (!force) {
|
||||
_header.emplace(std::move(key), std::move(val));
|
||||
_user_set_header.emplace(std::move(key), std::move(val));
|
||||
} else {
|
||||
_header[std::move(key)] = std::move(val);
|
||||
_user_set_header[std::move(key)] = std::move(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -181,6 +181,7 @@ private:
|
||||
bool _complete = false;
|
||||
string _url;
|
||||
HttpHeader _header;
|
||||
HttpHeader _user_set_header;
|
||||
HttpBody::Ptr _body;
|
||||
string _method;
|
||||
string _path;
|
||||
|
Loading…
Reference in New Issue
Block a user