mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-14 20:15:58 +08:00
http地址支持相对路径 (#2223)
* 部分hls中会出现类似[../]或者[./]的相对地址, 因此写了一个解析的方法 * 有时候上游http协议不规范会导致直接输出eof, 特别是在自动重试机制开启下, 容易造成定时器没办法初始化从而拉不到流但是session一直存在,所以需要做一个判断,如果没数据直接报错
This commit is contained in:
@@ -182,8 +182,8 @@ void HttpClient::onErr(const SockException &ex) {
|
||||
|
||||
ssize_t HttpClient::onRecvHeader(const char *data, size_t len) {
|
||||
_parser.Parse(data);
|
||||
if (_parser.Url() == "302" || _parser.Url() == "301") {
|
||||
auto new_url = _parser["Location"];
|
||||
if (_parser.Url() == "302" || _parser.Url() == "301" || _parser.Url() == "303") {
|
||||
auto new_url = Parser::merge_url(_url, _parser["Location"]);
|
||||
if (new_url.empty()) {
|
||||
throw invalid_argument("未找到Location字段(跳转url)");
|
||||
}
|
||||
@@ -206,7 +206,11 @@ ssize_t HttpClient::onRecvHeader(const char *data, size_t len) {
|
||||
onResponseBody(data, len);
|
||||
} else {
|
||||
_total_body_size = _recved_body_size;
|
||||
onResponseCompleted_l(SockException(Err_success, "success"));
|
||||
if (_recved_body_size > 0) {
|
||||
onResponseCompleted_l(SockException(Err_success, "success"));
|
||||
}else{
|
||||
onResponseCompleted_l(SockException(Err_other, "no body"));
|
||||
}
|
||||
}
|
||||
});
|
||||
//后续为源源不断的body
|
||||
|
||||
Reference in New Issue
Block a user