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 !
Fixed weird issue with content length when using net http post method. [#9 
state:resolved]
jnunemaker (author)
Tue Nov 25 22:26:32 -0800 2008
commit  a517168278eaa55ee4ee973a08dc092acd86c267
tree    a39495162479664bea8b4a62d0243f887af65d59
parent  f4c46223f4ec4845afbf017d1139866ac436a9b7
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+== 0.1.6 2008-11-26
0
+* 1 major enhancement
0
+  * now passing :query to set_form_data if post request to avoid content length errors
0
+  
0
 == 0.1.5 2008-11-14
0
 * 2 major enhancements
0
   * Refactored send request method out into its own object.
...
9
10
11
 
12
13
14
...
9
10
11
12
13
14
15
0
@@ -9,6 +9,7 @@ config/requirements.rb
0
 examples/aaws.rb
0
 examples/delicious.rb
0
 examples/google.rb
0
+examples/rubyurl.rb
0
 examples/twitter.rb
0
 examples/whoismyrep.rb
0
 httparty.gemspec
...
2
3
4
5
 
6
7
8
9
 
10
11
12
13
 
14
15
16
...
2
3
4
 
5
6
7
8
 
9
10
11
12
 
13
14
15
16
0
@@ -2,15 +2,15 @@
0
 
0
 Gem::Specification.new do |s|
0
   s.name = %q{httparty}
0
-  s.version = "0.1.5"
0
+  s.version = "0.1.6"
0
 
0
   s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
0
   s.authors = ["John Nunemaker"]
0
-  s.date = %q{2008-11-14}
0
+  s.date = %q{2008-11-26}
0
   s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
0
   s.email = ["nunemaker@gmail.com"]
0
   s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt"]
0
-  s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "examples/aaws.rb", "examples/delicious.rb", "examples/google.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "httparty.gemspec", "lib/httparty.rb", "lib/httparty/request.rb", "lib/httparty/version.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
0
+  s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "examples/aaws.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "httparty.gemspec", "lib/httparty.rb", "lib/httparty/request.rb", "lib/httparty/version.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
0
   s.has_rdoc = true
0
   s.homepage = %q{http://httparty.rubyforge.org}
0
   s.post_install_message = %q{When you HTTParty, you must party hard!}
...
37
38
39
40
 
 
41
42
43
...
99
100
101
 
 
 
 
 
102
103
104
...
37
38
39
 
40
41
42
43
44
...
100
101
102
103
104
105
106
107
108
109
110
0
@@ -37,7 +37,8 @@ module HTTParty
0
       end
0
       
0
       def get_response(uri) #:nodoc:
0
-        request = http_method.new(uri.request_uri)
0
+        request = http_method.new(uri.request_uri)   
0
+        request.set_form_data(options[:query]) if post? && options[:query]
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]
0
         request.basic_auth(options[:basic_auth][:username], options[:basic_auth][:password]) if options[:basic_auth]
0
@@ -99,6 +100,11 @@ module HTTParty
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
         raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].is_a?(Hash)
0
+        raise ArgumentError, ':query must be hash if using HTTP Post' if post? && !options[:query].nil? && !options[:query].is_a?(Hash)
0
+      end
0
+      
0
+      def post?
0
+        Net::HTTP::Post == http_method
0
       end
0
   end
0
 end
...
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  = 5
0
+    TINY  = 6
0
 
0
     STRING = [MAJOR, MINOR, TINY].join('.')
0
   end
...
105
106
107
 
 
 
 
 
 
 
 
108
...
105
106
107
108
109
110
111
112
113
114
115
116
0
@@ -105,3 +105,11 @@ describe HTTParty::Request do
0
     end
0
   end
0
 end
0
+
0
+describe HTTParty::Request, "with POST http method" do
0
+  it "should raise argument error if query is not a hash" do
0
+    lambda {
0
+      HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', :format => :xml, :query => 'astring').perform
0
+    }.should raise_error(ArgumentError)
0
+  end
0
+end
0
\ No newline at end of file

Comments