diff --git a/docs/manual.rst b/docs/manual.rst index fa10754d9..10c4beb5c 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -5945,7 +5945,7 @@ code symbol description ------ ----------------------------------------- ----------------------------------------------------------------- 81 packet_too_large The packet size exceeded the upper sanity check-limit ------ ----------------------------------------- ----------------------------------------------------------------- -82 http_parse_error Failed to parse HTTP response +82 reserved ------ ----------------------------------------- ----------------------------------------------------------------- 83 http_error The web server responded with an error ------ ----------------------------------------- ----------------------------------------------------------------- @@ -6006,15 +6006,15 @@ NAT-PMP errors: ====== ========================================= ================================================================= code symbol description ====== ========================================= ================================================================= -108 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version +120 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version ------ ----------------------------------------- ----------------------------------------------------------------- -109 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router +121 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router ------ ----------------------------------------- ----------------------------------------------------------------- -110 network_failure The NAT-PMP router failed because of a network failure +122 network_failure The NAT-PMP router failed because of a network failure ------ ----------------------------------------- ----------------------------------------------------------------- -111 no_resources The NAT-PMP router failed because of lack of resources +123 no_resources The NAT-PMP router failed because of lack of resources ------ ----------------------------------------- ----------------------------------------------------------------- -112 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent +124 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent ====== ========================================= ================================================================= fastresume data errors: @@ -6022,40 +6022,58 @@ fastresume data errors: ====== ========================================= ================================================================= code symbol description ====== ========================================= ================================================================= -113 missing_file_sizes The resume data file is missing the 'file sizes' entry +130 missing_file_sizes The resume data file is missing the 'file sizes' entry ------ --------HTTP/1.1 200 OK Date: Wed, 23 Jul 2025 04:21:45 GMT Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=7a8c489e16e68a15; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=GirGcD-dHYPeJkyvOVsaSDz3dfQ6MTc1MzI0NDUwNTk0NzM5MzQ0OQ; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN X-Cache-Status: HIT X-Cache-Age: 0 3000 diff --git a/docs/manual.rst b/docs/manual.rst index fa10754d9..10c4beb5c 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -5945,7 +5945,7 @@ code symbol description ------ ----------------------------------------- ----------------------------------------------------------------- 81 packet_too_large The packet size exceeded the upper sanity check-limit ------ ----------------------------------------- ----------------------------------------------------------------- -82 http_parse_error Failed to parse HTTP response +82 reserved ------ ----------------------------------------- ----------------------------------------------------------------- 83 http_error The web server responded with an error ------ ----------------------------------------- ----------------------------------------------------------------- @@ -6006,15 +6006,15 @@ NAT-PMP errors: ====== ========================================= ================================================================= code symbol description ====== ========================================= ================================================================= -108 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version +120 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version ------ ----------------------------------------- ----------------------------------------------------------------- -109 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router +121 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router ------ ----------------------------------------- ----------------------------------------------------------------- -110 network_failure The NAT-PMP router failed because of a network failure +122 network_failure The NAT-PMP router failed because of a network failure ------ ----------------------------------------- ----------------------------------------------------------------- -111 no_resources The NAT-PMP router failed because of lack of resources +123 no_resources The NAT-PMP router failed because of lack of resources ------ ----------------------------------------- ----------------------------------------------------------------- -112 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent +124 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent ====== ========================================= ================================================================= fastresume data errors: @@ -6022,40 +6022,58 @@ fastresume data errors: ====== ========================================= ================================================================= code symbol description ====== ========================================= ================================================================= -113 missing_file_sizes The resume data file is missing the 'file sizes' entry +130 missing_file_sizes The resume data file is missing the 'file sizes' entry ------ -------- a60 on your router)", "network failure", "out of resources", "unsupported opcode", + "", + "", + "", + "", + "", // fastresume errors "missing or invalid 'file sizes' entry", "no files in resume data", @@ -183,7 +200,18 @@ namespace libtorrent "", "", "", +// HTTP errors + "Invalid HTTP header", + "missing Location header in HTTP redirect", + "failed to decompress HTTP response", "", + "", + "", + "", + "", + "", + "", +// i2p errors "no i2p router is set up", }; if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0])) diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 5d10c37bc..2f35ed00c 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -489,7 +489,7 @@ void http_connection::callback(error_code const& e, char const* data, int size) std::string error; if (inflate_gzip(data, size, buf, max_bottled_buffer, error)) { - if (m_handler) m_handler(asio::error::fault, m_parser, data, size, *this); + if (m_handler) m_handler(errors::http_failed_decompress, m_parser, data, size, *this); close(); return; } @@ -584,7 +584,7 @@ void http_connection::on_read(error_code const& e if (error) { // HTTP parse error - error_code ec = asio::error::fault; + error_code ec = errors::http_parse_error; callback(ec, 0, 0); return; } @@ -601,7 +601,7 @@ void http_connection::on_read(error_code const& e if (location.empty()) { // missing location header - callback(asio::error::fault); + callback(error_code(errors::http_missing_location)); close(); return; } diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 779d4e59b..b54633877 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -371,6 +371,17 @@ int test_main() error_code ec; int ret = 0; + TEST_CHECK(error_code(errors::http_error).message() == "HTTP error"); + TEST_CHECK(error_code(errors::missing_file_sizes).message() == "missing or invalid 'file sizes' entry"); + TEST_CHECK(error_code(errors::unsupported_protocol_version).message() == "unsupported protocol version"); + TEST_CHECK(error_code(errors::no_i2p_router).message() == "no i2p router is set up"); + TEST_CHECK(error_code(errors::http_parse_error).message() == "Invalid HTTP header"); + TEST_CHECK(error_code(errors::error_code_max).message() == "Unknown error"); + + TEST_CHECK(errors::reserved129 == 129); + TEST_CHECK(errors::reserved159 == 159); + TEST_CHECK(errors::reserved108 == 108); + { // test session state load/restore session* s = new session(fingerprint("LT",0,0,0,0), 0); 0