lib/io_streams/paths/http.rb in iostreams-1.2.1 vs lib/io_streams/paths/http.rb in iostreams-1.3.0
- old
+ new
@@ -24,19 +24,22 @@
# password: [String]
# Password to use use with basic authentication when the username is supplied.
#
# http_redirect_count: [Integer]
# Maximum number of http redirects to follow.
- def initialize(url, username: nil, password: nil, http_redirect_count: 10)
+ def initialize(url, username: nil, password: nil, http_redirect_count: 10, parameters: nil)
uri = URI.parse(url)
unless %w[http https].include?(uri.scheme)
- raise(ArgumentError, "Invalid URL. Required Format: 'http://<host_name>/<file_name>', or 'https://<host_name>/<file_name>'")
+ raise(
+ ArgumentError,
+ "Invalid URL. Required Format: 'http://<host_name>/<file_name>', or 'https://<host_name>/<file_name>'"
+ )
end
@username = username || uri.user
@password = password || uri.password
@http_redirect_count = http_redirect_count
- @url = url
+ @url = parameters ? "#{url}?#{URI.encode_www_form(parameters)}" : url
super(uri.path)
end
# Does not support relative file names since there is no concept of current working directory
def relative?