代码润色
This commit is contained in:
parent
88dc59ec68
commit
98f7c37cd5
|
|
@ -8,13 +8,12 @@
|
||||||
* may be found in the AUTHORS file in the root of the source tree.
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Parser.h"
|
|
||||||
#include "Common/macros.h"
|
|
||||||
#include "Network/sockutil.h"
|
|
||||||
#include "Util/base64.h"
|
|
||||||
#include "macros.h"
|
|
||||||
#include "strCoding.h"
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include "Parser.h"
|
||||||
|
#include "strCoding.h"
|
||||||
|
#include "Util/base64.h"
|
||||||
|
#include "Network/sockutil.h"
|
||||||
|
#include "Common/macros.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
|
|
@ -344,6 +343,7 @@ void parseProxyUrl(const std::string &proxy_url, std::string &proxy_host, uint16
|
||||||
}
|
}
|
||||||
splitUrl(host, proxy_host, proxy_port);
|
splitUrl(host, proxy_host, proxy_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//测试代码
|
//测试代码
|
||||||
static onceToken token([](){
|
static onceToken token([](){
|
||||||
|
|
|
||||||
|
|
@ -411,9 +411,11 @@ void HttpClient::setBodyTimeout(size_t timeout_ms) {
|
||||||
void HttpClient::setCompleteTimeout(size_t timeout_ms) {
|
void HttpClient::setCompleteTimeout(size_t timeout_ms) {
|
||||||
_wait_complete_ms = timeout_ms;
|
_wait_complete_ms = timeout_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpClient::isUsedProxy() const {
|
bool HttpClient::isUsedProxy() const {
|
||||||
return _used_proxy;
|
return _used_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpClient::isProxyConnected() const {
|
bool HttpClient::isProxyConnected() const {
|
||||||
return _proxy_connected;
|
return _proxy_connected;
|
||||||
}
|
}
|
||||||
|
|
@ -434,5 +436,4 @@ bool HttpClient::checkProxyConnected(const char *data, size_t len) {
|
||||||
return _proxy_connected;
|
return _proxy_connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
|
|
|
||||||
|
|
@ -183,20 +183,17 @@ protected:
|
||||||
void onFlush() override;
|
void onFlush() override;
|
||||||
void onManager() override;
|
void onManager() override;
|
||||||
|
|
||||||
bool checkProxyConnected(const char *data, size_t len);
|
|
||||||
|
|
||||||
bool isUsedProxy() const;
|
|
||||||
|
|
||||||
bool isProxyConnected() const;
|
|
||||||
|
|
||||||
void clearResponse();
|
void clearResponse();
|
||||||
|
|
||||||
|
bool checkProxyConnected(const char *data, size_t len);
|
||||||
|
bool isUsedProxy() const;
|
||||||
|
bool isProxyConnected() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onResponseCompleted_l(const toolkit::SockException &ex);
|
void onResponseCompleted_l(const toolkit::SockException &ex);
|
||||||
void onConnect_l(const toolkit::SockException &ex);
|
void onConnect_l(const toolkit::SockException &ex);
|
||||||
void checkCookie(HttpHeader &headers);
|
void checkCookie(HttpHeader &headers);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//for http response
|
//for http response
|
||||||
bool _complete = false;
|
bool _complete = false;
|
||||||
|
|
@ -225,12 +222,13 @@ private:
|
||||||
toolkit::Ticker _wait_header;
|
toolkit::Ticker _wait_header;
|
||||||
toolkit::Ticker _wait_body;
|
toolkit::Ticker _wait_body;
|
||||||
toolkit::Ticker _wait_complete;
|
toolkit::Ticker _wait_complete;
|
||||||
|
|
||||||
|
bool _used_proxy = false;
|
||||||
|
bool _proxy_connected = false;
|
||||||
|
uint16_t _proxy_port;
|
||||||
std::string _proxy_url;
|
std::string _proxy_url;
|
||||||
std::string _proxy_host;
|
std::string _proxy_host;
|
||||||
std::string _proxy_auth;
|
std::string _proxy_auth;
|
||||||
uint16_t _proxy_port;
|
|
||||||
bool _proxy_connected = false;
|
|
||||||
bool _used_proxy = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ void HttpClientImp::onConnect(const SockException &ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t HttpClientImp::onRecvHeader(const char *data, size_t len) {
|
ssize_t HttpClientImp::onRecvHeader(const char *data, size_t len) {
|
||||||
if (isUsedProxy() && !isProxyConnected()) {
|
if (isUsedProxy() && !isProxyConnected()) {
|
||||||
if (checkProxyConnected(data, len)) {
|
if (checkProxyConnected(data, len)) {
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ const char *TSSegment::onSearchPacketTail(const char *data, size_t len) {
|
||||||
if (((uint8_t *) data)[_size] == TS_SYNC_BYTE) {
|
if (((uint8_t *) data)[_size] == TS_SYNC_BYTE) {
|
||||||
return data + _size;
|
return data + _size;
|
||||||
}
|
}
|
||||||
//搜索ts包头
|
auto pos = memchr(data + _size, TS_SYNC_BYTE, len - _size);
|
||||||
auto pos = memchr(data, TS_SYNC_BYTE, len);
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
return (char *) pos;
|
return (char *) pos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue