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 Oct 2, 2018
1 parent 88de44e commit 90bdb60
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 @@ -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]
Expand Down

0 comments on commit 90bdb60

Please sign in to comment.