Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use subclasses of Net::HTTPRequest instead of Net::HTTPGenericRequest #647

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion test/adapters/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def test_PATCH_send_url_encoded_params

def test_OPTIONS
resp = run_request(:options, 'echo', nil, {})
assert_equal 'options', resp.body

body = Faraday::TestCase.ruby_22_plus? ? 'options' : ''

assert_equal body, resp.body
end

def test_HEAD_retrieves_no_response_body
Expand Down