lib/zephyr.rb in zephyr-1.2.1 vs lib/zephyr.rb in zephyr-1.2.2
- old
+ new
@@ -245,10 +245,11 @@
# http.uri(['hi', 'bob', {:foo => 'bar'}]) => http://host/hi/bob?foo=bar
#
def uri(given_parts = [])
@root_uri.dup.tap do |uri|
parts = given_parts.dup.unshift(uri.path) # URI#merge is broken.
+ uri.query = Zephyr.build_query_string(parts.pop) if parts.last.is_a? Hash
uri.path = ('/%s' % parts.join('/')).gsub(/\/+/, '/')
end
end
# Comes handy in IRB
@@ -287,10 +288,14 @@
def perform(method, path_components, headers, expect, timeout, data=nil)
params = {}
params[:headers] = headers
params[:timeout] = timeout
params[:follow_location] = false
- params[:params] = path_components.pop if path_components.last.is_a?(Hash)
+
+ if path_components.last.is_a?(Hash) && (!data || data.empty?)
+ params[:params] = path_components.pop
+ end
+
params[:method] = method
# seriously, why is this on by default
Typhoeus::Hydra.hydra.disable_memoization