mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
Fix http cross domain issues
This commit is contained in:
parent
56bdb14baf
commit
cfe9a31ca6
@ -65,6 +65,7 @@ ssize_t HttpSession::onRecvHeader(const char *header, size_t len) {
|
|||||||
|
|
||||||
_parser.parse(header, len);
|
_parser.parse(header, len);
|
||||||
CHECK(_parser.url()[0] == '/');
|
CHECK(_parser.url()[0] == '/');
|
||||||
|
_origin = _parser["Origin"];
|
||||||
|
|
||||||
urlDecode(_parser);
|
urlDecode(_parser);
|
||||||
auto &cmd = _parser.method();
|
auto &cmd = _parser.method();
|
||||||
@ -606,8 +607,8 @@ void HttpSession::sendResponse(int code,
|
|||||||
headerOut.emplace("Connection", bClose ? "close" : "keep-alive");
|
headerOut.emplace("Connection", bClose ? "close" : "keep-alive");
|
||||||
|
|
||||||
GET_CONFIG(bool, allow_cross_domains, Http::kAllowCrossDomains);
|
GET_CONFIG(bool, allow_cross_domains, Http::kAllowCrossDomains);
|
||||||
if (allow_cross_domains) {
|
if (allow_cross_domains && !_origin.empty()) {
|
||||||
headerOut.emplace("Access-Control-Allow-Origin", "*");
|
headerOut.emplace("Access-Control-Allow-Origin", _origin);
|
||||||
headerOut.emplace("Access-Control-Allow-Credentials", "true");
|
headerOut.emplace("Access-Control-Allow-Credentials", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,8 @@ private:
|
|||||||
size_t _max_req_size = 0;
|
size_t _max_req_size = 0;
|
||||||
//消耗的总流量
|
//消耗的总流量
|
||||||
uint64_t _total_bytes_usage = 0;
|
uint64_t _total_bytes_usage = 0;
|
||||||
|
// http请求中的 Origin字段
|
||||||
|
std::string _origin;
|
||||||
Parser _parser;
|
Parser _parser;
|
||||||
toolkit::Ticker _ticker;
|
toolkit::Ticker _ticker;
|
||||||
TSMediaSource::RingType::RingReader::Ptr _ts_reader;
|
TSMediaSource::RingType::RingReader::Ptr _ts_reader;
|
||||||
|
Loading…
Reference in New Issue
Block a user