Commit f6e79584 by xzl

适配Android

parent ebf1c535
...@@ -55,7 +55,7 @@ void HttpClient::sendRequest(const string &strUrl){ ...@@ -55,7 +55,7 @@ void HttpClient::sendRequest(const string &strUrl){
_header.emplace(string("User-Agent"),"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"); _header.emplace(string("User-Agent"),"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
if(!_body.empty()){ if(!_body.empty()){
_header.emplace(string("Content-Length"),std::to_string(_body.size())); _header.emplace(string("Content-Length"),to_string(_body.size()));
_header.emplace(string("Content-Type"),"application/x-www-form-urlencoded; charset=UTF-8"); _header.emplace(string("Content-Type"),"application/x-www-form-urlencoded; charset=UTF-8");
} }
......
...@@ -27,10 +27,19 @@ void HttpClientImp::sendRequest(const string& url) { ...@@ -27,10 +27,19 @@ void HttpClientImp::sendRequest(const string& url) {
#else #else
_sslBox.reset(new SSL_Box(false)); _sslBox.reset(new SSL_Box(false));
_sslBox->setOnDecData([this](const char *data, uint32_t len){ _sslBox->setOnDecData([this](const char *data, uint32_t len){
#ifdef ANDROID
public_onRecvBytes(data,len);
#else//ANDROID
HttpClient::onRecvBytes(data,len); HttpClient::onRecvBytes(data,len);
#endif//ANDROID
}); });
_sslBox->setOnEncData([this](const char *data, uint32_t len){ _sslBox->setOnEncData([this](const char *data, uint32_t len){
#ifdef ANDROID
public_send(data,len);
#else//ANDROID
HttpClient::send(data,len); HttpClient::send(data,len);
#endif//ANDROID
}); });
#endif //ENABLE_OPENSSL #endif //ENABLE_OPENSSL
......
...@@ -23,6 +23,15 @@ public: ...@@ -23,6 +23,15 @@ public:
HttpClientImp(); HttpClientImp();
virtual ~HttpClientImp(); virtual ~HttpClientImp();
virtual void sendRequest(const string &url) override; virtual void sendRequest(const string &url) override;
#ifdef ANDROID
void public_onRecvBytes(const char *data,int len){
HttpClient::onRecvBytes(data,len);
}
void public_send(const char *data, uint32_t len){
HttpClient::send(data,len);
}
#endif //ANDROID
private: private:
#ifdef ENABLE_OPENSSL #ifdef ENABLE_OPENSSL
virtual void onRecvBytes(const char *data,int size) override; virtual void onRecvBytes(const char *data,int size) override;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论