diff --git a/lib/net/http.rb b/lib/net/http.rb index 4738bc6..844ce12 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1439,7 +1439,7 @@ def transport_request(req) begin res = HTTPResponse.read_new(@socket) res.decode_content = req.decode_content - end while res.kind_of?(HTTPContinue) + end while res.continue? res.uri = req.uri diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index e2964c4..2cdb777 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -120,6 +120,11 @@ def error! #:nodoc: raise error_type().new(@code + ' ' + @message.dump, self) end + # true if another response immediately follows this one + def continue? + self.class::CONTINUE + end + def error_type #:nodoc: self.class::EXCEPTION_TYPE end diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 8e75f75..697a8db 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -2,26 +2,32 @@ # :stopdoc: class Net::HTTPUnknownResponse < Net::HTTPResponse HAS_BODY = true + CONTINUE = false EXCEPTION_TYPE = Net::HTTPError end class Net::HTTPInformation < Net::HTTPResponse # 1xx HAS_BODY = false + CONTINUE = true EXCEPTION_TYPE = Net::HTTPError end class Net::HTTPSuccess < Net::HTTPResponse # 2xx HAS_BODY = true + CONTINUE = false EXCEPTION_TYPE = Net::HTTPError end class Net::HTTPRedirection < Net::HTTPResponse # 3xx HAS_BODY = true + CONTINUE = false EXCEPTION_TYPE = Net::HTTPRetriableError end class Net::HTTPClientError < Net::HTTPResponse # 4xx HAS_BODY = true + CONTINUE = false EXCEPTION_TYPE = Net::HTTPServerException # for backward compatibility end class Net::HTTPServerError < Net::HTTPResponse # 5xx HAS_BODY = true + CONTINUE = false EXCEPTION_TYPE = Net::HTTPFatalError # for backward compatibility end @@ -30,6 +36,7 @@ class Net::HTTPContinue < Net::HTTPInformation # 100 end class Net::HTTPSwitchProtocol < Net::HTTPInformation # 101 HAS_BODY = false + CONTINUE = false end # 102 - RFC 2518; removed in RFC 4918