diff --git a/http/vibe/http/client.d b/http/vibe/http/client.d index c8991a984c..a4debf8e94 100644 --- a/http/vibe/http/client.d +++ b/http/vibe/http/client.d @@ -557,19 +557,19 @@ final class HTTPClient { scope (failure) { m_responding = false; disconnect(); - break; } try responder(res); catch (Exception e) { logDebug("Error while handling response: %s", e.toString().sanitize()); user_exception = e; } - if (res.statusCode < 200) - { + if (res.statusCode < 200) { // just an informational status -> read and handle next response if (m_responding) res.dropBody(); - res = scoped!HTTPClientResponse(this, has_body, close_conn, request_allocator, connected_time); - continue; + if (m_conn) { + res = scoped!HTTPClientResponse(this, has_body, close_conn, request_allocator, connected_time); + continue; + } } if (m_responding) { logDebug("Failed to handle the complete response of the server - disconnecting."); diff --git a/http/vibe/http/server.d b/http/vibe/http/server.d index a311c0aa6d..cfcd324ed2 100644 --- a/http/vibe/http/server.d +++ b/http/vibe/http/server.d @@ -1539,6 +1539,7 @@ final class HTTPServerResponse : HTTPResponse { if (protocol.length) headers["Upgrade"] = protocol; writeVoidBody(); m_requiresConnectionClose = true; + m_headerWritten = true; return createConnectionProxyStream(m_conn, m_rawConnection); } /// ditto @@ -1548,6 +1549,7 @@ final class HTTPServerResponse : HTTPResponse { if (protocol.length) headers["Upgrade"] = protocol; writeVoidBody(); m_requiresConnectionClose = true; + m_headerWritten = true; () @trusted { auto conn = createConnectionProxyStreamFL(m_conn, m_rawConnection); del(conn);