Skip to content

Commit 0aba021

Browse files
authored
Merge pull request #328 from miyanyan/boost-1.87.0
support boost-1.87.0
2 parents da74ac4 + 0a89870 commit 0aba021

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

include/tgbot/net/BoostHttpOnlySslClient.h

+4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class TGBOT_API BoostHttpOnlySslClient : public HttpClient {
3333
std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override;
3434

3535
private:
36+
#if BOOST_VERSION >= 108700
37+
mutable boost::asio::io_context _ioService;
38+
#else
3639
mutable boost::asio::io_service _ioService;
40+
#endif
3741
const HttpParser _httpParser;
3842
};
3943

include/tgbot/net/HttpServer.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ class HttpServer {
159159
_startAccept();
160160
});
161161
}
162-
162+
#if BOOST_VERSION >= 108700
163+
boost::asio::io_context _ioService;
164+
#else
163165
boost::asio::io_service _ioService;
166+
#endif
164167
boost::asio::basic_socket_acceptor<Protocol> _acceptor;
165168
boost::asio::basic_stream_socket<Protocol> _socket;
166169
const ServerHandler _handler;

src/net/BoostHttpOnlySslClient.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ BoostHttpOnlySslClient::~BoostHttpOnlySslClient() {
1919

2020
string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqArg>& args) const {
2121
tcp::resolver resolver(_ioService);
22-
tcp::resolver::query query(url.host, "443");
2322

2423
ssl::context context(ssl::context::tlsv12_client);
2524
context.set_default_verify_paths();
2625

2726
ssl::stream<tcp::socket> socket(_ioService, context);
28-
27+
#if BOOST_VERSION >= 108700
28+
connect(socket.lowest_layer(), resolver.resolve(url.host, "443"));
29+
#else
30+
tcp::resolver::query query(url.host, "443");
2931
connect(socket.lowest_layer(), resolver.resolve(query));
32+
#endif
3033

3134
#ifdef TGBOT_DISABLE_NAGLES_ALGORITHM
3235
socket.lowest_layer().set_option(tcp::no_delay(true));
@@ -41,7 +44,11 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqA
4144
#endif //Processor architecture
4245
#endif //TGBOT_CHANGE_SOCKET_BUFFER_SIZE
4346
socket.set_verify_mode(ssl::verify_none);
47+
#if BOOST_VERSION >= 108700
48+
socket.set_verify_callback(ssl::host_name_verification(url.host));
49+
#else
4450
socket.set_verify_callback(ssl::rfc2818_verification(url.host));
51+
#endif
4552

4653
socket.handshake(ssl::stream<tcp::socket>::client);
4754

@@ -69,7 +76,11 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqA
6976
std::string sMsg("TIMEOUT on read client data. Client IP: ");
7077

7178
sMsg.append(socket.next_layer().remote_endpoint().address().to_string());
79+
#if BOOST_VERSION >= 108700
80+
_ioService.restart();
81+
#else
7282
_ioService.reset();
83+
#endif
7384

7485
throw std::exception();
7586
}

0 commit comments

Comments
 (0)