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 !
Got redirection all work properly and added example that checks it out.
jnunemaker (author)
Sat Nov 08 08:01:44 -0800 2008
commit  3101b5318b9476a9c7937f86581cddb623c820ee
tree    04ccd0e1846c9088e3df5b8f26679326fa44be56
parent  fda012a3347d2633667e594015e94f119a341787
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+== 0.1.4 2008-11-08
0
+* 1 major enhancement:
0
+  * Removed some cruft
0
+  * Added ability to follow redirects and turn that off (Alex Vollmer)
0
+
0
 == 0.1.3 2008-08-22
0
 
0
 * 3 major enhancements:
...
88
89
90
91
92
93
94
95
96
97
 
 
 
 
98
99
100
...
107
108
109
 
110
111
112
113
 
114
115
116
...
119
120
121
 
122
123
124
125
126
127
128
129
130
...
88
89
90
 
 
 
 
 
 
 
91
92
93
94
95
96
97
...
104
105
106
107
108
109
110
111
112
113
114
115
...
118
119
120
121
122
123
124
125
126
 
127
128
129
0
@@ -88,13 +88,10 @@ module HTTParty
0
     
0
     private
0
       def http(uri) #:nodoc:
0
-        if @http.blank?
0
-          @http = Net::HTTP.new(uri.host, uri.port, @http_proxyaddr, @http_proxyport)
0
-          @http.use_ssl = (uri.port == 443)
0
-          # so we can avoid ssl warnings
0
-          @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
0
-        end
0
-        @http
0
+        http = Net::HTTP.new(uri.host, uri.port, @http_proxyaddr, @http_proxyport)
0
+        http.use_ssl = (uri.port == 443)
0
+        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
0
+        http
0
       end
0
       
0
       # FIXME: this method is doing way to much and needs to be split up
0
@@ -107,10 +104,12 @@ module HTTParty
0
       def send_request(method, path, options={}) #:nodoc:
0
         options = {:limit => 5}.merge(options)
0
         options[:limit] = 0 if options.delete(:no_follow)
0
+        
0
         raise HTTParty::RedirectionTooDeep, 'HTTP redirects too deep' if options[:limit].to_i <= 0
0
         raise ArgumentError, 'only get, post, put and delete methods are supported' unless %w[get post put delete].include?(method.to_s)
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
         path           = URI.parse(path)
0
         uri            = path.relative? ? URI.parse("#{base_uri}#{path}") : path
0
         existing_query = uri.query ? "#{uri.query}&" : ''
0
@@ -119,12 +118,12 @@ module HTTParty
0
         else
0
           existing_query + (options[:query].is_a?(Hash) ? default_params.merge(options[:query]).to_query : options[:query])
0
         end
0
+        
0
         klass          = Net::HTTP.const_get method.to_s.downcase.capitalize
0
         request        = klass.new(uri.request_uri)
0
         request.body   = options[:body].is_a?(Hash) ? options[:body].to_query : options[:body] unless options[:body].blank?
0
         basic_auth     = options.delete(:basic_auth) || @auth
0
         request.initialize_http_header headers.merge(options[:headers] || {})
0
-        # note to self: self, do not put basic auth above headers because it removes basic auth
0
         request.basic_auth(basic_auth[:username], basic_auth[:password]) if basic_auth
0
         response       = http(uri).request(request)
0
         @format      ||= format_from_mimetype(response['content-type'])
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ module HTTParty
0
   module VERSION #:nodoc:
0
     MAJOR = 0
0
     MINOR = 1
0
-    TINY  = 3
0
+    TINY  = 4
0
 
0
     STRING = [MAJOR, MINOR, TINY].join('.')
0
   end

Comments