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 !
Switched from send to perform which sounds fancier.
jnunemaker (author)
Tue Nov 11 16:07:11 -0800 2008
commit  67cb57256ff8ee1d3703fbe9fb8b8a1adf39a473
tree    3fe64f20a815f55bf6801117d0486f338c1e16bd
parent  c67b6d4f01b9e01438da4ce3aa92f32828806eb3
...
71
72
73
74
 
75
76
77
78
79
 
80
81
82
83
84
 
85
86
87
88
89
 
90
91
92
93
94
95
 
 
96
97
98
...
71
72
73
 
74
75
76
77
78
 
79
80
81
82
83
 
84
85
86
87
88
 
89
90
91
92
93
 
 
94
95
96
97
98
0
@@ -71,28 +71,28 @@ module HTTParty
0
     
0
     # TODO: spec out this
0
     def get(path, options={})
0
-      send_request Net::HTTP::Get, path, options
0
+      perform_request Net::HTTP::Get, path, options
0
     end
0
 
0
     # TODO: spec out this    
0
     def post(path, options={})
0
-      send_request Net::HTTP::Post, path, options
0
+      perform_request Net::HTTP::Post, path, options
0
     end
0
 
0
     # TODO: spec out this    
0
     def put(path, options={})
0
-      send_request Net::HTTP::Put, path, options
0
+      perform_request Net::HTTP::Put, path, options
0
     end
0
 
0
     # TODO: spec out this    
0
     def delete(path, options={})
0
-      send_request Net::HTTP::Delete, path, options
0
+      perform_request Net::HTTP::Delete, path, options
0
     end
0
 
0
     private
0
 
0
-      def send_request(http_method, path, options)
0
-        Request.send_request(http_method, path, default_options.merge(options))
0
+      def perform_request(http_method, path, options)
0
+        Request.perform_request(http_method, path, default_options.merge(options))
0
       end
0
     
0
       # Makes it so uri is sure to parse stuff like google.com with the http
...
2
3
4
5
6
 
 
7
8
9
...
28
29
30
31
 
32
33
34
...
36
37
38
39
40
41
42
...
63
64
65
66
 
67
68
69
70
71
72
73
74
75
...
2
3
4
 
 
5
6
7
8
9
...
28
29
30
 
31
32
33
34
...
36
37
38
 
39
40
41
...
62
63
64
 
65
66
67
68
69
70
 
71
72
73
0
@@ -2,8 +2,8 @@ module HTTParty
0
   class Request
0
     SupportedHTTPMethods = [Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete]
0
 
0
-    def self.send_request(http_method, path, options={})
0
-      new(http_method, path, options).send_request
0
+    def self.perform_request(http_method, path, options={})
0
+      new(http_method, path, options).perform
0
     end
0
 
0
     attr_accessor :http_method, :path, :options
0
@@ -28,7 +28,7 @@ module HTTParty
0
     #   headers     => hash of headers to send request with
0
     #   basic_auth  => :username and :password to use as basic http authentication (overrides basic_auth setting)
0
     # Raises exception Net::XXX (http error code) if an http error occured
0
-    def send_request #:nodoc:
0
+    def perform #:nodoc:
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 SupportedHTTPMethods.include?(http_method)
0
       raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].is_a?(Hash)
0
@@ -36,7 +36,6 @@ module HTTParty
0
       
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
@@ -63,13 +62,12 @@ module HTTParty
0
       when Net::HTTPRedirection
0
         options[:limit] -= 1
0
         self.path = response['location']
0
-        send_request
0
+        perform
0
       else
0
         response.instance_eval { class << self; attr_accessor :body_parsed; end }
0
         begin; response.body_parsed = parse_response(response.body); rescue; end
0
         response.error! # raises  exception corresponding to http error Net::XXX
0
       end
0
-
0
     end
0
 
0
     private

Comments