Skip to content

Commit

Permalink
Use subclasses of Net::HTTPRequest instead of Net::HTTPGenericRequest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fotos committed Dec 26, 2016
1 parent e66210b commit eb27d01
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit eb27d01

Please sign in to comment.