http_request.rb 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +4 -1
- data/README.rdoc +8 -7
- data/lib/http_request.rb +3 -3
- metadata +2 -2
data/Changelog
CHANGED
data/README.rdoc
CHANGED
@@ -27,16 +27,17 @@ include http_request.rb first
|
|
27
27
|
or install it "gem install http_request.rb", then require 'http_request'
|
28
28
|
|
29
29
|
get
|
30
|
-
puts HttpRequest.get('http://www.github.com')
|
30
|
+
puts HttpRequest.get('http://www.github.com').body
|
31
31
|
|
32
32
|
get with query string, 4 are same
|
33
|
-
puts HttpRequest.get('http://www.google.com/search?hl=en&q=ruby&start=0&sa=N')
|
34
|
-
puts HttpRequest.get(
|
35
|
-
puts HttpRequest.get(
|
36
|
-
puts HttpRequest.get({:url => 'http://www.google.com/search', :parameters =>
|
33
|
+
puts HttpRequest.get('http://www.google.com/search?hl=en&q=ruby&start=0&sa=N').body
|
34
|
+
puts HttpRequest.get('http://www.google.com/search', :parameters => 'hl=en&q=ruby&start=0&sa=N').body
|
35
|
+
puts HttpRequest.get(:url => 'http://www.google.com/search', :parameters => 'hl=en&q=ruby&start=0&sa=N').body
|
36
|
+
puts HttpRequest.get({:url => 'http://www.google.com/search', :parameters => 'hl=en&q=ruby&start=0&sa=N'}).body
|
37
|
+
puts HttpRequest.get({:url => 'http://www.google.com/search', :parameters => {:hl => 'en', :q => 'ruby', :start => 0, :sa => 'N'}}).body
|
37
38
|
|
38
39
|
post with some parameters
|
39
|
-
puts HttpRequest.get(
|
40
|
+
puts HttpRequest.get('http://localhost/test.php', :parameters => 'from=http_request.rb').body
|
40
41
|
puts HttpRequest.get(:url => 'http://localhost/test.php', :parameters => {:name => 'Ruby', :time => 'Now'}).body
|
41
42
|
|
42
43
|
also support other http methods, such as put, delete, trace, options, move etc.
|
@@ -227,4 +228,4 @@ download multiple files from a directory
|
|
227
228
|
bug fixing, testing and testing...
|
228
229
|
|
229
230
|
== LATEST VERSION
|
230
|
-
1.1.
|
231
|
+
1.1.10
|
data/lib/http_request.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# == Version
|
13
13
|
#
|
14
|
-
# v1.1.
|
14
|
+
# v1.1.10
|
15
15
|
#
|
16
16
|
# Last Change: 13 Sep, 2010
|
17
17
|
#
|
@@ -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.10'.freeze
|
36
36
|
def version;VERSION;end
|
37
37
|
|
38
38
|
# avaiabled http methods
|
@@ -104,7 +104,7 @@ class HttpRequest
|
|
104
104
|
end
|
105
105
|
@@redirect_times = 0
|
106
106
|
# we need to retrieve the cookies from last http response before reset cookies if it's a Net::HTTPResponse
|
107
|
-
options[:cookies] = options[:cookies].cookies if options[:cookies].is_a?
|
107
|
+
options[:cookies] = options[:cookies].cookies if options.is_a?(Hash) and options[:cookies].is_a?(Net::HTTPResponse)
|
108
108
|
@@__cookies = {}
|
109
109
|
method_name = method_name.to_s.downcase
|
110
110
|
raise NoHttpMethodException, "No such http method can be called: #{method_name}" unless self.http_methods.include?(method_name)
|