Permalink
Browse files

extracted encoded path preparation

  • Loading branch information...
1 parent 87d152b commit 21eadf00d24d487ba1d54ab2beedd2e2df5b4312 Diego Scataglini committed Sep 20, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/databasedotcom/client.rb
@@ -310,15 +310,19 @@ def http_multipart_post(path, parts, parameters={}, headers={})
def within_request(path, opts = {}, parameters={}, headers={})
req = Net::HTTP.new(URI.parse(self.instance_url).host, 443)
req.use_ssl = true
- path_parameters = (parameters || {}).collect { |k, v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join('&')
- encoded_path = [URI.escape(path), path_parameters.empty? ? nil : path_parameters].compact.join('?')
+ encoded_path = prepare_encoded_path_from(path, parameters)
log_request(encoded_path, opts[:data]) #data is passed only in post
result = yield(req, encoded_path)
log_response(result)
raise SalesForceError.new(result) unless result.is_a?(opts[:expected_result_class] || Net::HTTPSuccess)
result
end
+ def prepare_encoded_path_from(path, parameters={})
+ path_parameters = (parameters || {}).collect { |k, v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join('&')
+ [URI.escape(path), path_parameters.empty? ? nil : path_parameters].compact.join('?')
+ end
+
def log_request(path, data=nil)
puts "***** REQUEST: #{path.include?(':') ? path : URI.join(self.instance_url, path)}#{data ? " => #{data}" : ''}" if self.debugging
end

0 comments on commit 21eadf0

Please sign in to comment.