Skip to content

Commit

Permalink
Improve connection:close handling for HTTP clients. (#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaff committed Dec 8, 2020
1 parent 039ee74 commit 0826d2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sming/Core/Network/Http/HttpClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ int HttpClientConnection::onMessageComplete(http_parser* parser)
// if the server does not support keep-alive -> close the connection
// see: https://tools.ietf.org/html/rfc2616#section-14.10
debug_d("HCC::onMessageComplete: Closing as requested by server");
close();
state = eHCS_WaitResponse; // put the other requests on hold...
setTimeOut(0); // schedule for closing...

return hasError;
}
Expand Down Expand Up @@ -312,7 +313,6 @@ void HttpClientConnection::onClosed()
debug_d("HCC::onClosed: Trying to reconnect and send pending requests");

cleanup();
init(HTTP_RESPONSE);
auto request = waitingQueue.peek();
if(request != nullptr) {
bool useSsl = (request->uri.Scheme == URI_SCHEME_HTTP_SECURE);
Expand Down
1 change: 1 addition & 0 deletions Sming/Core/Network/Http/HttpClientConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class HttpClientConnection : public HttpConnection
{
if(err == ERR_OK) {
state = eHCS_Ready;
init(HTTP_RESPONSE);
}

return HttpConnection::onConnected(err);
Expand Down

0 comments on commit 0826d2c

Please sign in to comment.