Commit 242e1b03 authored by Tiago's avatar Tiago
Browse files

http1 fix: handle the case where the response is an error response

parent cdd8c674
Loading
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -197,9 +197,10 @@ module HTTPX
    end

    def handle_error(ex, request = nil)
      if (ex.is_a?(EOFError) || ex.is_a?(TimeoutError)) && @request && @request.response &&
         !@request.response.headers.key?("content-length") &&
         !@request.response.headers.key?("transfer-encoding")
      if (ex.is_a?(EOFError) || ex.is_a?(TimeoutError)) && @request &&
         (response = @request.response) && response.is_a?(Response) &&
         !response.headers.key?("content-length") &&
         !response.headers.key?("transfer-encoding")
        # if the response does not contain a content-length header, the server closing the
        # connnection is the indicator of response consumed.
        # https://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.4