Compare commits

...

2 Commits

Author SHA1 Message Date
Wayne Chen
dfca520857
修复http代理的两个问题,原http代理功能提交(#2988):d593267 (#4219)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
1. CONNECT请求添加Host字段, 解决400 bad request问题;
    2. HLS拉取第2个ts分片时,重新设置http代理,解决第2个分片及后续分片未走代理的问题。
2025-04-10 15:09:46 +08:00
guohuachan
8ff1459789
doc: update readme.md (#4238)
zlmediakit exporter 已经完善,整体完成度较高。
并且 grafana_demo 服务器更换了更大带宽的服务器,访问更稳定。

希望能加入合作项目,感谢感谢☺️
2025-04-10 15:07:09 +08:00
4 changed files with 21 additions and 3 deletions

View File

@ -229,6 +229,9 @@ bash build_docker_images.sh
- [c# sdk](https://github.com/malegend/ZLMediaKit.Autogen) 本项目c sdk完整c#包装库 - [c# sdk](https://github.com/malegend/ZLMediaKit.Autogen) 本项目c sdk完整c#包装库
- [metaRTC](https://github.com/metartc/metaRTC) 全国产纯c webrtc sdk - [metaRTC](https://github.com/metartc/metaRTC) 全国产纯c webrtc sdk
- 监控与运维
- [ZLMediaKit_exporter](https://github.com/guohuachan/ZLMediaKit_exporter) 一个用于采集 ZLMediaKit 核心指标的 Prometheus Exporter搭配 Grafana 即可快速构建实时监控面板
- 其他项目(已停止更新) - 其他项目(已停止更新)
- [NodeJS实现的GB28181平台](https://gitee.com/hfwudao/GB28181_Node_Http) - [NodeJS实现的GB28181平台](https://gitee.com/hfwudao/GB28181_Node_Http)
- [基于ZLMediaKit主线的管理WEB网站 ](https://gitee.com/kkkkk5G/MediaServerUI) - [基于ZLMediaKit主线的管理WEB网站 ](https://gitee.com/kkkkk5G/MediaServerUI)

View File

@ -404,6 +404,8 @@ bash build_docker_images.sh
- [GB28181 player implemented in C++](https://github.com/any12345com/BXC_gb28181Player) - [GB28181 player implemented in C++](https://github.com/any12345com/BXC_gb28181Player)
- [Android RTCPlayer](https://github.com/leo94666/RTCPlayer) - [Android RTCPlayer](https://github.com/leo94666/RTCPlayer)
- Monitor
- [Prometheus Exporter for ZLMediaKit](https://github.com/guohuachan/ZLMediaKit_exporter)
## License ## License

View File

@ -133,6 +133,10 @@ void HlsPlayer::fetchSegment() {
if (!(*this)[Client::kNetAdapter].empty()) { if (!(*this)[Client::kNetAdapter].empty()) {
_http_ts_player->setNetAdapter((*this)[Client::kNetAdapter]); _http_ts_player->setNetAdapter((*this)[Client::kNetAdapter]);
} }
} else {
// 每次请求新的ts片段时重置HttpTSPlayer状态
_http_ts_player->clear();
_http_ts_player->setProxyUrl((*this)[Client::kProxyUrl]);
} }
Ticker ticker; Ticker ticker;

View File

@ -103,6 +103,8 @@ void HttpClient::clear() {
_user_set_header.clear(); _user_set_header.clear();
_body.reset(); _body.reset();
_method.clear(); _method.clear();
// 重置代理连接状态
_proxy_connected = false;
clearResponse(); clearResponse();
} }
@ -182,6 +184,8 @@ void HttpClient::onConnect_l(const SockException &ex) {
_path.clear(); _path.clear();
} else { } else {
printer << "CONNECT " << _last_host << " HTTP/1.1\r\n"; printer << "CONNECT " << _last_host << " HTTP/1.1\r\n";
printer << "Host: " << _last_host << "\r\n";
printer << "User-Agent: " << kServerName << "\r\n";
printer << "Proxy-Connection: keep-alive\r\n"; printer << "Proxy-Connection: keep-alive\r\n";
if (!_proxy_auth.empty()) { if (!_proxy_auth.empty()) {
printer << "Proxy-Authorization: Basic " << _proxy_auth << "\r\n"; printer << "Proxy-Authorization: Basic " << _proxy_auth << "\r\n";
@ -482,9 +486,14 @@ void HttpClient::setProxyUrl(string proxy_url) {
} }
bool HttpClient::checkProxyConnected(const char *data, size_t len) { bool HttpClient::checkProxyConnected(const char *data, size_t len) {
auto ret = strstr(data, "HTTP/1.1 200 Connection established"); string response(data, len);
_proxy_connected = ret != nullptr; if (response.find("HTTP/1.1 200") != string::npos || response.find("HTTP/1.0 200") != string::npos) {
return _proxy_connected; _proxy_connected = true;
return true;
}
_proxy_connected = false;
return false;
} }
void HttpClient::setAllowResendRequest(bool allow) { void HttpClient::setAllowResendRequest(bool allow) {