1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

remove warnings about URI.escape when available

This commit is contained in:
Jon Rowe 2013-07-31 21:34:51 +10:00
parent 924acc6317
commit 0919b02cc5
2 changed files with 12 additions and 2 deletions

View file

@ -147,12 +147,17 @@ module RestClient
# for UrlEncoded escape the keys
def handle_key key
URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
parser.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
def headers
super.merge({'Content-Type' => 'application/x-www-form-urlencoded'})
end
private
def parser
URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
class Multipart < Base

View file

@ -137,7 +137,7 @@ module RestClient
if p[k].is_a? Hash
process_payload(p[k], key)
else
value = URI.escape(p[k].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
value = parser.escape(p[k].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
"#{key}=#{value}"
end
end.join("&")
@ -312,6 +312,11 @@ module RestClient
{:accept => '*/*; q=0.5, application/xml', :accept_encoding => 'gzip, deflate'}
end
private
def parser
URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
end