mirror of
https://github.com/wownero/lwsf-wow.git
synced 2026-10-17 07:21:28 +02:00
A few HTTP fixes
This commit is contained in:
+15
-9
@@ -73,8 +73,6 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
|
|
||||||
case error::none:
|
case error::none:
|
||||||
return "No rpc errors";
|
return "No rpc errors";
|
||||||
case error::timeout:
|
|
||||||
return "No response from HTTP server";
|
|
||||||
case error::invalid_code:
|
case error::invalid_code:
|
||||||
return "Invalid status code from HTTP server";
|
return "Invalid status code from HTTP server";
|
||||||
}
|
}
|
||||||
@@ -229,6 +227,7 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
const std::uint16_t port;
|
const std::uint16_t port;
|
||||||
std::atomic<bool> is_connected;
|
std::atomic<bool> is_connected;
|
||||||
epee::net_utils::ssl_support_t ssl_status;
|
epee::net_utils::ssl_support_t ssl_status;
|
||||||
|
bool retry; //! in case of connection timeouts, etc
|
||||||
|
|
||||||
client_state(boost::asio::io_context& io, std::string host, std::string prefix, const std::uint16_t port, epee::net_utils::ssl_options_t in, std::function<connect_func> connect)
|
client_state(boost::asio::io_context& io, std::string host, std::string prefix, const std::uint16_t port, epee::net_utils::ssl_options_t in, std::function<connect_func> connect)
|
||||||
: buffer{},
|
: buffer{},
|
||||||
@@ -247,7 +246,8 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
iteration(0),
|
iteration(0),
|
||||||
port(port),
|
port(port),
|
||||||
is_connected(false),
|
is_connected(false),
|
||||||
ssl_status(ssl.support)
|
ssl_status(ssl.support),
|
||||||
|
retry(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
@@ -262,7 +262,7 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
outgoing.front().verb,
|
outgoing.front().verb,
|
||||||
outgoing.front().target,
|
outgoing.front().target,
|
||||||
config::http_version,
|
config::http_version,
|
||||||
std::move(outgoing.front().body)
|
outgoing.front().body.clone()
|
||||||
};
|
};
|
||||||
request.set(boost::beast::http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
request.set(boost::beast::http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||||
if (!no_body)
|
if (!no_body)
|
||||||
@@ -312,12 +312,12 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
sock.next_layer().close(ignore);
|
sock.next_layer().close(ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_connection_error()
|
void notify_connection_error(const boost::system::error_code error)
|
||||||
{
|
{
|
||||||
for (auto& elem : outgoing)
|
for (auto& elem : outgoing)
|
||||||
{
|
{
|
||||||
if (elem.notifier)
|
if (elem.notifier)
|
||||||
elem.notifier(error::timeout, {});
|
elem.notifier(error, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
outgoing.clear();
|
outgoing.clear();
|
||||||
@@ -429,7 +429,7 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return self.notify_connection_error();
|
return self.notify_connection_error(error);
|
||||||
|
|
||||||
++self.iteration;
|
++self.iteration;
|
||||||
self.is_connected = true;
|
self.is_connected = true;
|
||||||
@@ -468,10 +468,17 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
|
|
||||||
// if write, read, or parse errors
|
// if write, read, or parse errors
|
||||||
if (error)
|
if (error)
|
||||||
return self.notify_connection_error();
|
{
|
||||||
|
if (!self.retry)
|
||||||
|
return self.notify_connection_error(error);
|
||||||
|
self.retry = false;
|
||||||
|
self.close();
|
||||||
|
return client_loop{self_}(); // possible timeout; connect retry
|
||||||
|
}
|
||||||
|
|
||||||
self.outgoing.pop_front();
|
self.outgoing.pop_front();
|
||||||
++self.iteration;
|
++self.iteration;
|
||||||
|
self.retry = true;
|
||||||
|
|
||||||
if (!self.parser->get().keep_alive())
|
if (!self.parser->get().keep_alive())
|
||||||
{
|
{
|
||||||
@@ -569,7 +576,6 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
|
|
||||||
frame_->resolver.cancel();
|
frame_->resolver.cancel();
|
||||||
self_->close();
|
self_->close();
|
||||||
frame_->f(boost::asio::error::operation_aborted);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ namespace lwsf { namespace internal { namespace http
|
|||||||
{
|
{
|
||||||
enum class error : int
|
enum class error : int
|
||||||
{
|
{
|
||||||
none = 0, timeout = -1, invalid_code = -2 /* Otherwise HTTP error code */
|
none = 0, invalid_code = -1 /* Otherwise HTTP error code */
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::error_category& error_category() noexcept;
|
const std::error_category& error_category() noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user