Permalink
Browse files

updated for v1.1.5

  • Loading branch information...
1 parent cc09c46 commit cd57b1bc94c69fcd7f2a2fcb94f9dd7f772a5f1a @xianhuazhou committed May 8, 2010
Showing with 26 additions and 6 deletions.
  1. +7 −0 Changelog
  2. +1 −1 README.rdoc
  3. +1 −1 http_request.gemspec
  4. +10 −4 lib/http_request.rb
  5. +7 −0 test/test_http_request.rb
View
@@ -1,3 +1,10 @@
+v1.1.5
+ * use get(url, :parameters => 'a=3') instead of get(:url => url,
+ :parameters => 'a=3'), old style still works.
+
+v1.1.4
+ * always use "get" method for redirection
+
v1.1.3
* fixed a bug of the number of redirection checking
View
@@ -227,7 +227,7 @@ download multiple files from a directory
bug fixing, testing and testing...
== LATEST VERSION
- 1.1.3
+ 1.1.5
== Author
View
@@ -3,7 +3,7 @@ SPEC=Gem::Specification.new do |s|
s.homepage = 'http://my.cnzxh.net'
s.rubyforge_project = "http_request.rb"
s.name = 'http_request.rb'
- s.version = '1.1.3'
+ s.version = '1.1.5'
s.author = 'xianhua.zhou'
s.email = 'xianhua.zhou@gmail.com'
s.platform = Gem::Platform::RUBY
View
@@ -11,9 +11,9 @@
#
# == Version
#
-# v1.1.3
+# v1.1.5
#
-# Last Change: 29 Dec, 2009
+# Last Change: 8 May, 2010
#
# == Author
#
@@ -32,7 +32,7 @@ class HttpRequest
include Singleton
class << self
# version
- VERSION = '1.1.3'.freeze
+ VERSION = '1.1.5'.freeze
def version;VERSION;end
# avaiabled http methods
@@ -96,7 +96,12 @@ def request(method, options, &block)
end
# catch all available http requests
- def self.method_missing(method_name, options, &block)
+ def self.method_missing(method_name, *options, &block)
+ options = if options.size.eql? 2
+ options.last.merge({:url => options.first})
+ else
+ options.first
+ end
@@redirect_times = 0
# we need to retrieve the cookies from last http response before reset cookies if it's a Net::HTTPResponse
options[:cookies] = options[:cookies].cookies if options[:cookies].is_a? Net::HTTPResponse
@@ -412,6 +417,7 @@ def process_redirection(response, &block)
@options[:cookies] = @options[:cookies].update self.class.cookies
end
@options.delete :parameters
+ @options.delete :method
request('get', @options, &block)
else
data(response, &block)
@@ -26,6 +26,9 @@
hr.get(:url => URL + "/ajax").body.should.equal 'N'
hr.get(:url => URL + "/ajax", :xhr => true).body.should.equal 'Y'
hr.get(:url => URL + "/ajax", :ajax => true).body.should.equal 'Y'
+
+ hr.get(URL + "/ajax", :xhr => true).body.should.equal 'Y'
+ hr.get(URL + "/ajax", :ajax => true).body.should.equal 'Y'
end
specify "available http methods" do
@@ -80,6 +83,10 @@
'lang' => 'Ruby', 'version' => '1.9'
}.inspect)
+ hr.get(URL + '/get', :parameters => {'lang' => 'Ruby', 'version' => '1.9'}).body.should.equal({
+ 'lang' => 'Ruby', 'version' => '1.9'
+ }.inspect)
+
hr.get(URL + '/get?ids[]=1&ids[]=2').body.should.equal({
'ids' => ['1', '2']
}.inspect)

0 comments on commit cd57b1b

Please sign in to comment.