lib/filbunke/client.rb in filbunke-2.1.6 vs lib/filbunke/client.rb in filbunke-2.1.7

- old
+ new

@@ -116,11 +116,11 @@ register_path = "/#{FILES_ACTION}/#{@repository.name}/#{path}?#{URL_KEY}=#{url}" register_path += "&#{HASH_KEY}=#{hash}" if hash begin register_http = Net::HTTP.new(@repository.host, @repository.port) register_http.start do |http| - request = Net::HTTP::Put.new(URI.escape(register_path)) + request = Net::HTTP::Put.new(Addressable::URI.encode(register_path)) response = http.request(request) if response.code.to_i != 204 raise "Failed to register updated file: #{path}" end end @@ -133,11 +133,11 @@ def register_deleted_file!(path) register_path = "/#{FILES_ACTION}/#{@repository.name}/#{path}" begin register_http = Net::HTTP.new(@repository.host, @repository.port) register_http.start do |http| - request = Net::HTTP::Delete.new(URI.escape(register_path)) + request = Net::HTTP::Delete.new(Addressable::URI.encode(register_path)) response = http.request(request) if response.code.to_i != 204 raise "Failed to register deleted file: #{path}" end end @@ -149,11 +149,11 @@ def touch_repository! touch_http = Net::HTTP.new(@repository.host, @repository.port) touch_http.start do |http| touch_path = "/#{UPDATES_ACTION}/#{@repository.name}/#{TOUCH_ACTION}" - request = Net::HTTP::Put.new(URI.escape(touch_path)) + request = Net::HTTP::Put.new(Addressable::URI.encode(touch_path)) response = http.request(request) if response.code.to_i != 204 raise "Failed to touch repository: #{@repository.name}" end end @@ -161,11 +161,11 @@ def fetch_remote_last_checkpoint last_checkpoint_http = Net::HTTP.new(@repository.host, @repository.port) last_checkpoint_http.start do |http| last_checkpoint_path = "/#{UPDATES_ACTION}/#{@repository.name}/#{LAST_CHECKPOINT_ACTION}" - request = Net::HTTP::Get.new(URI.escape(last_checkpoint_path)) + request = Net::HTTP::Get.new(Addressable::URI.encode(last_checkpoint_path)) response = http.request(request) if response.code.to_i != 200 raise "Failed to get last checkpoint for repository: #{@repository.name}" end return response.body.chomp.to_i @@ -227,11 +227,11 @@ updates_http.start do |http| updates_path = "/#{UPDATES_ACTION}/#{@repository.name}?#{FROM_CHECKPOINT_KEY}=#{last_checkpoint}" updates_path = "#{updates_path}&batch_size=#{@repository.batch_size}" if @repository.batch_size > 0 begin @logger.info "Fetching updated file list from #{updates_path}" - request = Net::HTTP::Get.new(URI.escape(updates_path)) + request = Net::HTTP::Get.new(Addressable::URI.encode(updates_path)) response = http.request(request) if response.code.to_i == 200 JSON.parse(response.body) else @logger.error "Failed to download updates for #{@repository.name}, error code = #{response.code}" @@ -252,17 +252,17 @@ downloaded_file = nil tmp_filename = "#{local_file_path}.tmp" begin async_request = if @repository.user Typhoeus::Request.new( - URI.escape(file.url), + Addressable::URI.encode(file.url), :followlocation => true, :username => @repository.user, :password => @repository.pass ) else Typhoeus::Request.new( - URI.escape(file.url), + Addressable::URI.encode(file.url), :followlocation => true ) end async_request.on_headers do |response|