http_request.rb 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +4 -0
- data/README.rdoc +1 -1
- data/lib/http_request.rb +9 -4
- data/test/test_http_request.rb +7 -0
- metadata +12 -5
data/Changelog
CHANGED
data/README.rdoc
CHANGED
data/lib/http_request.rb
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
#
|
12
12
|
# == Version
|
13
13
|
#
|
14
|
-
# v1.1.
|
14
|
+
# v1.1.5
|
15
15
|
#
|
16
|
-
# Last Change:
|
16
|
+
# Last Change: 8 May, 2010
|
17
17
|
#
|
18
18
|
# == Author
|
19
19
|
#
|
@@ -32,7 +32,7 @@ class HttpRequest
|
|
32
32
|
include Singleton
|
33
33
|
class << self
|
34
34
|
# version
|
35
|
-
VERSION = '1.1.
|
35
|
+
VERSION = '1.1.5'.freeze
|
36
36
|
def version;VERSION;end
|
37
37
|
|
38
38
|
# avaiabled http methods
|
@@ -96,7 +96,12 @@ class HttpRequest
|
|
96
96
|
end
|
97
97
|
|
98
98
|
# catch all available http requests
|
99
|
-
def self.method_missing(method_name, options, &block)
|
99
|
+
def self.method_missing(method_name, *options, &block)
|
100
|
+
options = if options.size.eql? 2
|
101
|
+
options.last.merge({:url => options.first})
|
102
|
+
else
|
103
|
+
options.first
|
104
|
+
end
|
100
105
|
@@redirect_times = 0
|
101
106
|
# we need to retrieve the cookies from last http response before reset cookies if it's a Net::HTTPResponse
|
102
107
|
options[:cookies] = options[:cookies].cookies if options[:cookies].is_a? Net::HTTPResponse
|
data/test/test_http_request.rb
CHANGED
@@ -26,6 +26,9 @@ context "some basic http requests" do
|
|
26
26
|
hr.get(:url => URL + "/ajax").body.should.equal 'N'
|
27
27
|
hr.get(:url => URL + "/ajax", :xhr => true).body.should.equal 'Y'
|
28
28
|
hr.get(:url => URL + "/ajax", :ajax => true).body.should.equal 'Y'
|
29
|
+
|
30
|
+
hr.get(URL + "/ajax", :xhr => true).body.should.equal 'Y'
|
31
|
+
hr.get(URL + "/ajax", :ajax => true).body.should.equal 'Y'
|
29
32
|
end
|
30
33
|
|
31
34
|
specify "available http methods" do
|
@@ -80,6 +83,10 @@ context "some basic requests with parameter" do
|
|
80
83
|
'lang' => 'Ruby', 'version' => '1.9'
|
81
84
|
}.inspect)
|
82
85
|
|
86
|
+
hr.get(URL + '/get', :parameters => {'lang' => 'Ruby', 'version' => '1.9'}).body.should.equal({
|
87
|
+
'lang' => 'Ruby', 'version' => '1.9'
|
88
|
+
}.inspect)
|
89
|
+
|
83
90
|
hr.get(URL + '/get?ids[]=1&ids[]=2').body.should.equal({
|
84
91
|
'ids' => ['1', '2']
|
85
92
|
}.inspect)
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_request.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 5
|
9
|
+
version: 1.1.5
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- xianhua.zhou
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-05-08 00:00:00 +08:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -40,18 +45,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
45
|
requirements:
|
41
46
|
- - ">="
|
42
47
|
- !ruby/object:Gem::Version
|
48
|
+
segments:
|
49
|
+
- 0
|
43
50
|
version: "0"
|
44
|
-
version:
|
45
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
52
|
requirements:
|
47
53
|
- - ">="
|
48
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
49
57
|
version: "0"
|
50
|
-
version:
|
51
58
|
requirements: []
|
52
59
|
|
53
60
|
rubyforge_project: http_request.rb
|
54
|
-
rubygems_version: 1.3.
|
61
|
+
rubygems_version: 1.3.6
|
55
62
|
signing_key:
|
56
63
|
specification_version: 3
|
57
64
|
summary: http_request.rb is a small, lightweight, powerful HttpRequest class based on the 'net/http' and 'net/ftp' libraries
|