lib/convert_api/client.rb in convert_api-1.2.0 vs lib/convert_api/client.rb in convert_api-1.2.1
- old
+ new
@@ -46,11 +46,11 @@
end
def upload(io, filename)
handle_response do
request_uri = base_uri.path + 'upload'
- encoded_filename = URI.encode(filename)
+ encoded_filename = CGI.escape(filename)
headers = DEFAULT_HEADERS.merge(
'Content-Type' => 'application/octet-stream',
'Transfer-Encoding' => 'chunked',
'Content-Disposition' => "attachment; filename*=UTF-8''#{encoded_filename}",
@@ -89,13 +89,13 @@
raise(ConnectionFailed, e)
rescue Timeout::Error, Errno::ETIMEDOUT => e
raise(TimeoutError, e)
end
- def http(read_timeout: nil)
+ def http(options = {})
http = Net::HTTP.new(base_uri.host, base_uri.port)
http.open_timeout = config.connect_timeout
- http.read_timeout = read_timeout || config.read_timeout
+ http.read_timeout = options.fetch(:read_timeout, config.read_timeout)
http.use_ssl = base_uri.scheme == 'https'
# http.set_debug_output $stderr
http
end