lib/httpi/request.rb in httpi-2.2.5 vs lib/httpi/request.rb in httpi-2.2.6

- old
+ new

@@ -33,11 +33,11 @@ # Sets the +query+ from +url+. Raises an +ArgumentError+ unless the +url+ is valid. def query=(query) raise ArgumentError, "Invalid URL: #{self.url}" unless self.url.respond_to?(:query) if query.kind_of?(Hash) - query = Rack::Utils.build_query(query) + query = build_query_from_hash(query) end query = query.to_s unless query.is_a?(String) self.url.query = query end @@ -94,11 +94,11 @@ attr_accessor :open_timeout, :read_timeout attr_reader :body # Sets a body request given a String or a Hash. def body=(params) - @body = params.kind_of?(Hash) ? Rack::Utils.build_query(params) : params + @body = params.kind_of?(Hash) ? build_query_from_hash(params) : params end # Sets the block to be called while processing the response. The block # accepts a single parameter - the chunked response body. def on_body(&block) @@ -139,9 +139,14 @@ # Expects a +url+, validates its validity and returns a +URI+ object. def normalize_url!(url) raise ArgumentError, "Invalid URL: #{url}" unless url.to_s =~ /^http/ url.kind_of?(URI) ? url : URI(url) + end + + # Returns a +query+ string given a +Hash+ + def build_query_from_hash(query) + HTTPI.query_builder.build(query) end end end