From e7742489ca2f69d697cf7a26559cbedc7f508bd8 Mon Sep 17 00:00:00 2001
From: Seva <seva@binarytrails.net>
Date: Mon, 26 Aug 2019 20:13:01 -0400
Subject: [PATCH] http: ignore rw ops on closed connection

---
 src/http.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/http.cpp b/src/http.cpp
index 3e545246..11f076b1 100644
--- a/src/http.cpp
+++ b/src/http.cpp
@@ -214,6 +214,8 @@ Connection::async_handshake(HandlerCb cb)
 void
 Connection::async_write(BytesHandlerCb cb)
 {
+    if (!is_open())
+        return;
     if (ssl_ctx_)
         asio::async_write(*ssl_socket_, write_buf_, cb);
     else
@@ -223,6 +225,8 @@ Connection::async_write(BytesHandlerCb cb)
 void
 Connection::async_read_until(const char* delim, BytesHandlerCb cb)
 {
+    if (!is_open())
+        return;
     if (ssl_ctx_)
         asio::async_read_until(*ssl_socket_, read_buf_, delim, cb);
     else
@@ -232,6 +236,8 @@ Connection::async_read_until(const char* delim, BytesHandlerCb cb)
 void
 Connection::async_read(const size_t bytes, BytesHandlerCb cb)
 {
+    if (!is_open())
+        return;
     if (ssl_socket_)
         asio::async_read(*ssl_socket_, read_buf_, asio::transfer_exactly(bytes), cb);
     else
-- 
GitLab