mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-19 06:42:21 +08:00
Charset default to UTF-8 on Windows
This commit is contained in:
@@ -66,7 +66,8 @@ void HttpClient::sendRequest(const string &url) {
|
||||
_http_persistent = true;
|
||||
if (_body && _body->remainSize()) {
|
||||
_header.emplace("Content-Length", to_string(_body->remainSize()));
|
||||
_header.emplace("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
GET_CONFIG(string, charSet, Http::kCharSet);
|
||||
_header.emplace("Content-Type", "application/x-www-form-urlencoded; charset=" + charSet);
|
||||
}
|
||||
|
||||
bool host_changed = (_last_host != host + ":" + to_string(port)) || (_is_https != is_https);
|
||||
|
||||
@@ -683,34 +683,10 @@ void HttpSession::sendResponse(int code,
|
||||
AsyncSender::onSocketFlushed(data);
|
||||
}
|
||||
|
||||
string HttpSession::urlDecodePath(const string &str) {
|
||||
auto ret = strCoding::UrlDecodePath(str);
|
||||
#ifdef _WIN32
|
||||
GET_CONFIG(string, charSet, Http::kCharSet);
|
||||
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
|
||||
if (isGb2312) {
|
||||
ret = strCoding::UTF8ToGB2312(ret);
|
||||
}
|
||||
#endif // _WIN32
|
||||
return ret;
|
||||
}
|
||||
|
||||
string HttpSession::urlDecodeComponent(const string &str) {
|
||||
auto ret = strCoding::UrlDecodeComponent(str);
|
||||
#ifdef _WIN32
|
||||
GET_CONFIG(string, charSet, Http::kCharSet);
|
||||
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
|
||||
if (isGb2312) {
|
||||
ret = strCoding::UTF8ToGB2312(ret);
|
||||
}
|
||||
#endif // _WIN32
|
||||
return ret;
|
||||
}
|
||||
|
||||
void HttpSession::urlDecode(Parser &parser) {
|
||||
parser.setUrl(urlDecodePath(parser.url()));
|
||||
parser.setUrl(strCoding::UrlDecodePath(parser.url()));
|
||||
for (auto &pr : _parser.getUrlArgs()) {
|
||||
const_cast<string &>(pr.second) = urlDecodeComponent(pr.second);
|
||||
const_cast<string &>(pr.second) = strCoding::UrlDecodeComponent(pr.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ public:
|
||||
void onRecv(const toolkit::Buffer::Ptr &) override;
|
||||
void onError(const toolkit::SockException &err) override;
|
||||
void onManager() override;
|
||||
static std::string urlDecodePath(const std::string &str);
|
||||
static std::string urlDecodeComponent(const std::string &str);
|
||||
void setTimeoutSec(size_t second);
|
||||
void setMaxReqSize(size_t max_req_size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user