Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.

Commit f74752d

Browse files
committed
Update vendor lib
1 parent ccf8494 commit f74752d

File tree

12 files changed

+987
-721
lines changed

12 files changed

+987
-721
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ include_directories(${VCPKG_INCLUDE_DIR})
1313
include_directories(src)
1414

1515
add_definitions(-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
16-
-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
17-
-D_SCL_SECURE_NO_WARNINGS
1816
-D_WIN32_WINNT=0x0501
1917
-DWIN32_LEAN_AND_MEAN
18+
-DNOMINMAX
2019
-DCURL_STATICLIB)
2120

2221
find_package(Boost REQUIRED COMPONENTS filesystem)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Simple-Web-Server: v3.0.0-rc3
2+
Simple-WebSocket-Server: v2.0.0-rc4

src/cqhttp/plugins/web/vendor/simple_web/client_ws.hpp

Lines changed: 237 additions & 126 deletions
Large diffs are not rendered by default.

src/cqhttp/plugins/web/vendor/simple_web/server_http.hpp

Lines changed: 320 additions & 174 deletions
Large diffs are not rendered by default.

src/cqhttp/plugins/web/vendor/simple_web/server_https.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
#include <openssl/ssl.h>
1414

1515
namespace SimpleWeb {
16-
typedef asio::ssl::stream<asio::ip::tcp::socket> HTTPS;
16+
using HTTPS = asio::ssl::stream<asio::ip::tcp::socket>;
1717

1818
template <>
1919
class Server<HTTPS> : public ServerBase<HTTPS> {
20-
std::string session_id_context;
2120
bool set_session_id_context = false;
2221

2322
public:
@@ -33,31 +32,32 @@ namespace SimpleWeb {
3332
}
3433
}
3534

36-
void start() override {
35+
protected:
36+
asio::ssl::context context;
37+
38+
void after_bind() override {
3739
if(set_session_id_context) {
3840
// Creating session_id_context from address:port but reversed due to small SSL_MAX_SSL_SESSION_ID_LENGTH
39-
session_id_context = std::to_string(config.port) + ':';
41+
auto session_id_context = std::to_string(acceptor->local_endpoint().port()) + ':';
4042
session_id_context.append(config.address.rbegin(), config.address.rend());
4143
SSL_CTX_set_session_id_context(context.native_handle(), reinterpret_cast<const unsigned char *>(session_id_context.data()),
42-
std::min<size_t>(session_id_context.size(), SSL_MAX_SSL_SESSION_ID_LENGTH));
44+
std::min<std::size_t>(session_id_context.size(), SSL_MAX_SSL_SESSION_ID_LENGTH));
4345
}
44-
ServerBase::start();
4546
}
4647

47-
protected:
48-
asio::ssl::context context;
49-
5048
void accept() override {
51-
auto session = std::make_shared<Session>(create_connection(*io_service, context));
49+
auto connection = create_connection(*io_service, context);
5250

53-
acceptor->async_accept(session->connection->socket->lowest_layer(), [this, session](const error_code &ec) {
54-
auto cancel_pair = session->connection->cancel_handlers_bool_and_lock();
55-
if(cancel_pair.first)
51+
acceptor->async_accept(connection->socket->lowest_layer(), [this, connection](const error_code &ec) {
52+
auto lock = connection->handler_runner->continue_lock();
53+
if(!lock)
5654
return;
5755

5856
if(ec != asio::error::operation_aborted)
5957
this->accept();
6058

59+
auto session = std::make_shared<Session>(config.max_request_streambuf_size, connection);
60+
6161
if(!ec) {
6262
asio::ip::tcp::no_delay option(true);
6363
error_code ec;
@@ -66,11 +66,11 @@ namespace SimpleWeb {
6666
session->connection->set_timeout(config.timeout_request);
6767
session->connection->socket->async_handshake(asio::ssl::stream_base::server, [this, session](const error_code &ec) {
6868
session->connection->cancel_timeout();
69-
auto cancel_pair = session->connection->cancel_handlers_bool_and_lock();
70-
if(cancel_pair.first)
69+
auto lock = session->connection->handler_runner->continue_lock();
70+
if(!lock)
7171
return;
7272
if(!ec)
73-
this->read_request_and_content(session);
73+
this->read(session);
7474
else if(this->on_error)
7575
this->on_error(session->request, ec);
7676
});

0 commit comments

Comments
 (0)