30
30
#include " brzip.hpp"
31
31
#endif
32
32
#include " cinatra_log_wrapper.hpp"
33
+ #include " error.hpp"
33
34
#include " http_parser.hpp"
34
35
#include " multipart.hpp"
35
36
#include " picohttpparser.h"
@@ -355,7 +356,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
355
356
data = co_await connect (u);
356
357
}
357
358
if (socket_->is_timeout_ ) {
358
- co_return resp_data{std:: make_error_code (std::errc::timed_out ), 404 };
359
+ co_return resp_data{make_error_code (http_errc::connect_timeout ), 404 };
359
360
}
360
361
if (!data.net_err ) {
361
362
data.status = 200 ;
@@ -715,7 +716,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
715
716
data = co_await connect (u);
716
717
}
717
718
if (socket_->is_timeout_ ) {
718
- co_return resp_data{std:: make_error_code (std::errc::timed_out ), 404 };
719
+ co_return resp_data{make_error_code (http_errc::connect_timeout ), 404 };
719
720
}
720
721
if (data.net_err ) {
721
722
co_return data;
@@ -743,7 +744,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
743
744
744
745
if (data.net_err ) {
745
746
if (socket_->is_timeout_ ) {
746
- data.net_err = std:: make_error_code (std::errc::timed_out );
747
+ data.net_err = make_error_code (http_errc::request_timeout );
747
748
}
748
749
co_return data;
749
750
}
@@ -754,7 +755,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
754
755
if (std::tie (ec, size) = co_await async_write (asio::buffer (last_part));
755
756
ec) {
756
757
if (socket_->is_timeout_ ) {
757
- ec = std:: make_error_code (std::errc::timed_out );
758
+ ec = make_error_code (http_errc::request_timeout );
758
759
}
759
760
co_return resp_data{ec, 404 };
760
761
}
@@ -763,7 +764,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
763
764
data = co_await handle_read (ec, size, is_keep_alive, std::move (ctx),
764
765
http_method::POST);
765
766
if (socket_->is_timeout_ ) {
766
- ec = std:: make_error_code (std::errc::timed_out );
767
+ ec = make_error_code (http_errc::request_timeout );
767
768
}
768
769
handle_result (data, ec, is_keep_alive);
769
770
co_return data;
@@ -1097,7 +1098,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1097
1098
data = co_await connect (u);
1098
1099
}
1099
1100
if (socket_->is_timeout_ ) {
1100
- co_return resp_data{std:: make_error_code (std::errc::timed_out ), 404 };
1101
+ co_return resp_data{make_error_code (http_errc::connect_timeout ), 404 };
1101
1102
}
1102
1103
if (data.net_err ) {
1103
1104
co_return data;
@@ -1108,7 +1109,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1108
1109
std::tie (ec, size) = co_await async_write (asio::buffer (header_str));
1109
1110
if (ec) {
1110
1111
if (socket_->is_timeout_ ) {
1111
- ec = std:: make_error_code (std::errc::timed_out );
1112
+ ec = make_error_code (http_errc::request_timeout );
1112
1113
}
1113
1114
co_return resp_data{ec, 404 };
1114
1115
}
@@ -1179,15 +1180,15 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1179
1180
}
1180
1181
if (ec) {
1181
1182
if (socket_->is_timeout_ ) {
1182
- ec = std:: make_error_code (std::errc::timed_out );
1183
+ ec = make_error_code (http_errc::request_timeout );
1183
1184
}
1184
1185
co_return resp_data{ec, 404 };
1185
1186
}
1186
1187
1187
1188
data = co_await handle_read (ec, size, is_keep_alive, std::move (ctx),
1188
1189
http_method::POST);
1189
1190
if (ec && socket_->is_timeout_ ) {
1190
- ec = std:: make_error_code (std::errc::timed_out );
1191
+ ec = make_error_code (http_errc::request_timeout );
1191
1192
}
1192
1193
handle_result (data, ec, is_keep_alive);
1193
1194
co_return data;
@@ -1253,7 +1254,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1253
1254
data = co_await connect (u);
1254
1255
}
1255
1256
if (socket_->is_timeout_ ) {
1256
- co_return resp_data{std:: make_error_code (std::errc::timed_out ), 404 };
1257
+ co_return resp_data{make_error_code (http_errc::connect_timeout ), 404 };
1257
1258
}
1258
1259
if (data.net_err ) {
1259
1260
co_return data;
@@ -1264,7 +1265,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1264
1265
std::tie (ec, size) = co_await async_write (asio::buffer (header_str));
1265
1266
if (ec) {
1266
1267
if (socket_->is_timeout_ ) {
1267
- ec = std:: make_error_code (std::errc::timed_out );
1268
+ ec = make_error_code (http_errc::request_timeout );
1268
1269
}
1269
1270
co_return resp_data{ec, 404 };
1270
1271
}
@@ -1319,15 +1320,15 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1319
1320
}
1320
1321
if (ec) {
1321
1322
if (socket_->is_timeout_ ) {
1322
- ec = std:: make_error_code (std::errc::timed_out );
1323
+ ec = make_error_code (http_errc::request_timeout );
1323
1324
}
1324
1325
co_return resp_data{ec, 404 };
1325
1326
}
1326
1327
1327
1328
data = co_await handle_read (ec, size, is_keep_alive, std::move (ctx),
1328
1329
http_method::POST);
1329
1330
if (ec && socket_->is_timeout_ ) {
1330
- ec = std:: make_error_code (std::errc::timed_out );
1331
+ ec = make_error_code (http_errc::request_timeout );
1331
1332
}
1332
1333
handle_result (data, ec, is_keep_alive);
1333
1334
co_return data;
@@ -1397,7 +1398,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1397
1398
}
1398
1399
1399
1400
if (socket_->is_timeout_ ) {
1400
- data.net_err = std:: make_error_code (std::errc::timed_out );
1401
+ data.net_err = make_error_code (http_errc::connect_timeout );
1401
1402
co_return data;
1402
1403
}
1403
1404
@@ -1460,7 +1461,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1460
1461
co_await handle_read (ec, size, is_keep_alive, std::move (ctx), method);
1461
1462
} while (0 );
1462
1463
if (ec && socket_->is_timeout_ ) {
1463
- ec = std:: make_error_code (std::errc::timed_out );
1464
+ ec = make_error_code (http_errc::request_timeout );
1464
1465
}
1465
1466
handle_result (data, ec, is_keep_alive);
1466
1467
co_return data;
@@ -2086,7 +2087,7 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
2086
2087
}
2087
2088
2088
2089
if (socket_->is_timeout_ ) {
2089
- auto ec = std:: make_error_code (std::errc::timed_out );
2090
+ auto ec = make_error_code (http_errc::connect_timeout );
2090
2091
co_return resp_data{ec, 404 };
2091
2092
}
2092
2093
0 commit comments