mirror of
https://github.com/lostisland/faraday.git
synced 2025-12-16 00:03:23 -05:00
Merge pull request #514 from lostisland/no-port-number
Fix default port numbers for Net::HTTP adapters
This commit is contained in:
commit
cc9772bfdf
@ -92,7 +92,7 @@ module Faraday
|
|||||||
Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:user], proxy[:password])
|
Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:user], proxy[:password])
|
||||||
else
|
else
|
||||||
Net::HTTP
|
Net::HTTP
|
||||||
end.new(env[:url].host, env[:url].port)
|
end.new(env[:url].host, env[:url].port || (env[:url].scheme == 'https' ? 443 : 80))
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_ssl(http, ssl)
|
def configure_ssl(http, ssl)
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
require File.expand_path('../integration', __FILE__)
|
require File.expand_path('../integration', __FILE__)
|
||||||
|
require 'ostruct'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
module Adapters
|
module Adapters
|
||||||
class NetHttpTest < Faraday::TestCase
|
class NetHttpTest < Faraday::TestCase
|
||||||
@ -10,5 +12,34 @@ module Adapters
|
|||||||
|
|
||||||
Integration.apply(self, *behaviors)
|
Integration.apply(self, *behaviors)
|
||||||
|
|
||||||
|
def test_no_explicit_http_port_number
|
||||||
|
url = URI('http://example.com')
|
||||||
|
url.port = nil
|
||||||
|
|
||||||
|
adapter = Faraday::Adapter::NetHttp.new
|
||||||
|
http = adapter.net_http_connection(:url => url, :request => {})
|
||||||
|
|
||||||
|
assert_equal 80, http.port
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_no_explicit_https_port_number
|
||||||
|
url = URI('https://example.com')
|
||||||
|
url.port = nil
|
||||||
|
|
||||||
|
adapter = Faraday::Adapter::NetHttp.new
|
||||||
|
http = adapter.net_http_connection(:url => url, :request => {})
|
||||||
|
|
||||||
|
assert_equal 443, http.port
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_explicit_port_number
|
||||||
|
url = URI('https://example.com:1234')
|
||||||
|
|
||||||
|
adapter = Faraday::Adapter::NetHttp.new
|
||||||
|
http = adapter.net_http_connection(:url => url, :request => {})
|
||||||
|
|
||||||
|
assert_equal 1234, http.port
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user