1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Added URI::Generic to supported URL schemes

This commit is contained in:
Cory Kaufman-Schofield 2012-09-17 15:33:00 -04:00
parent d392c2d1cb
commit 5d4967ab05
2 changed files with 15 additions and 6 deletions

View file

@ -10,7 +10,7 @@ module HTTParty
Net::HTTP::Options
]
SupportedURISchemes = [URI::HTTP, URI::HTTPS]
SupportedURISchemes = [URI::HTTP, URI::HTTPS, URI::Generic]
NON_RAILS_QUERY_STRING_NORMALIZER = Proc.new do |query|
Array(query).map do |key, value|
@ -42,6 +42,14 @@ module HTTParty
@path = URI.parse(uri)
end
def request_uri(uri)
if uri.respond_to? :request_uri
uri.request_uri
else
uri.path
end
end
def uri
new_uri = path.relative? ? URI.parse("#{base_uri}#{path}") : path
@ -51,7 +59,7 @@ module HTTParty
end
unless SupportedURISchemes.include? new_uri.class
raise UnsupportedURIScheme, "'#{new_uri}' Must be HTTP or HTTPS"
raise UnsupportedURIScheme, "'#{new_uri}' Must be HTTP, HTTPS or Generic"
end
@last_uri = new_uri
@ -130,7 +138,7 @@ module HTTParty
end
def setup_raw_request
@raw_request = http_method.new(uri.request_uri)
@raw_request = http_method.new(request_uri(uri))
@raw_request.body = body if body
@raw_request.initialize_http_header(options[:headers])
@raw_request.basic_auth(username, password) if options[:basic_auth]

View file

@ -688,10 +688,11 @@ describe HTTParty do
end.should_not raise_error(HTTParty::UnsupportedURIScheme)
end
it "should raise an ArgumentError on URIs that are not http or https" do
it "should accept webcal URIs" do
stub_http_response_with('google.html')
lambda do
HTTParty.get("file:///there_is_no_party_on/my/filesystem")
end.should raise_error(HTTParty::UnsupportedURIScheme)
HTTParty.get('webcal://google.com')
end.should_not raise_error(HTTParty::UnsupportedURIScheme)
end
it "should raise an InvalidURIError on URIs that can't be parsed at all" do