From 90bdb6080ae9747b220a04f49e76e64fe9388079 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 d2f8cec95..e26b51d4c 100644 --- a/lib/faraday/adapter/net_http.rb +++ b/lib/faraday/adapter/net_http.rb @@ -64,12 +64,10 @@ def call(env) private 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]