From eb27d01fb5215cf06aff79947e59dd568e85bcb2 Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Mon, 26 Dec 2016 14:57:24 +0000 Subject: [PATCH] Use subclasses of Net::HTTPRequest instead of Net::HTTPGenericRequest Instead of directly instantiating Net::HTTPGenericRequest, use the appropriate Net::HTTPRequest subclass. Fixes a problem with net-http-persistent adapter that is checking the subclasses of Net::HTTPRequest for idempotence support. --- lib/faraday/adapter/net_http.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/faraday/adapter/net_http.rb b/lib/faraday/adapter/net_http.rb index 1a4244fac..30dce003d 100644 --- a/lib/faraday/adapter/net_http.rb +++ b/lib/faraday/adapter/net_http.rb @@ -60,12 +60,10 @@ def call(env) end def create_request(env) - request = Net::HTTPGenericRequest.new \ - env[:method].to_s.upcase, # request method - !!env[:body], # is there request body - :head != env[:method], # is there response body - env[:url].request_uri, # request uri path - env[:request_headers] # request headers + klass = Net::HTTP.const_get(env[:method].to_s.capitalize) + request = klass.new \ + env[:url].request_uri, # request uri path + env[:request_headers] # request headers if env[:body].respond_to?(:read) request.body_stream = env[:body]