public
Rubygem
Description: Makes http fun! Also, makes consuming restful web services dead easy.
Homepage:
Clone URL: git://github.com/jnunemaker/httparty.git
Click here to lend your support to: httparty and make a donation at www.pledgie.com !
Everything seems to be working once again since the minor refactoring.
jnunemaker (author)
Tue Nov 11 15:58:53 -0800 2008
commit  c67b6d4f01b9e01438da4ce3aa92f32828806eb3
tree    922e57d3894a5655833bc05c568e8c82ffd5de8c
parent  c3e2a57083f91b93bda22e7427307020d0ecacc3
...
21
22
23
24
25
26
27
28
29
30
...
38
39
40
41
42
43
 
 
 
 
 
 
 
 
44
45
 
 
46
47
 
 
48
49
50
...
21
22
23
 
 
 
 
24
25
26
...
34
35
36
 
 
 
37
38
39
40
41
42
43
44
45
 
46
47
48
49
50
51
52
53
54
0
@@ -21,10 +21,6 @@ module HTTParty
0
       @path = URI.parse(uri)
0
     end
0
 
0
-    def uri
0
-      path.relative? ? URI.parse("#{options[:base_uri]}#{path}") : path
0
-    end
0
-
0
     # FIXME: this method is doing way to much and needs to be split up
0
     # options can be any or all of:
0
     #   query       => hash of keys/values or a query string (foo=bar&baz=poo)
0
@@ -38,13 +34,21 @@ module HTTParty
0
       raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].is_a?(Hash)
0
       raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].is_a?(Hash)
0
       
0
-      existing_query = uri.query ? "#{uri.query}&" : ''
0
-      uri.query      = if options[:query].blank?
0
-        existing_query + options[:default_params].to_query
0
+      uri = path.relative? ? URI.parse("#{options[:base_uri]}#{path}") : path
0
+      
0
+      
0
+      query_string_parts = []
0
+      query_string_parts << uri.query unless uri.query.blank?
0
+      
0
+      if options[:query].is_a?(Hash)
0
+        query_string_parts << options[:default_params].merge(options[:query]).to_query
0
       else
0
-        existing_query + (options[:query].is_a?(Hash) ? options[:default_params].merge(options[:query]).to_query : options[:query])
0
+        query_string_parts << options[:default_params].to_query unless options[:default_params].blank?
0
+        query_string_parts << options[:query] unless options[:query].blank?
0
       end
0
       
0
+      uri.query = query_string_parts.join('&') if query_string_parts.size > 0
0
+      
0
       request        = http_method.new(uri.request_uri)
0
       request.body   = options[:body].is_a?(Hash) ? options[:body].to_query : options[:body] unless options[:body].blank?
0
       request.initialize_http_header options[:headers]

Comments