From 53fbb257b97d52a2146683c2ed9382bfcc7fb747 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 5 May 2019 19:03:56 -0500 Subject: [PATCH] Update fix for HTTP Client --- src/invidious/helpers/handlers.cr | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr index bc1a3896..4e73df51 100644 --- a/src/invidious/helpers/handlers.cr +++ b/src/invidious/helpers/handlers.cr @@ -199,7 +199,7 @@ class DenyFrame < Kemal::Handler end end -# Temp fix for https://github.com/crystal-lang/crystal/issues/7383 +# Temp fixes for https://github.com/crystal-lang/crystal/issues/7383 class HTTP::UnknownLengthContent def read_byte ensure_send_continue @@ -209,3 +209,18 @@ class HTTP::UnknownLengthContent @io.read_byte end end + +class HTTP::Client + private def handle_response(response) + if @socket.is_a?(OpenSSL::SSL::Socket::Client) + close unless response.keep_alive? || @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty? + if @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty? + @socket = nil + end + else + close unless response.keep_alive? + end + + response + end +end