http-request 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/http-request.rb +6 -11
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/http-request.rb
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
require 'net/http'
|
34
34
|
|
35
35
|
class HttpRequest
|
36
|
-
VERSION = '1.0.
|
36
|
+
VERSION = '1.0.2'
|
37
37
|
|
38
38
|
class HTTPError < StandardError; end
|
39
39
|
class UnexpectedError < StandardError; end
|
@@ -48,6 +48,10 @@ class HttpRequest
|
|
48
48
|
attr_accessor :body
|
49
49
|
attr_accessor :status
|
50
50
|
|
51
|
+
class << self
|
52
|
+
attr_accessor :user_agent, :timeout
|
53
|
+
end
|
54
|
+
|
51
55
|
|
52
56
|
def self.head(url, options={})
|
53
57
|
http = HttpRequest.new(url)
|
@@ -59,15 +63,6 @@ class HttpRequest
|
|
59
63
|
http.get(options)
|
60
64
|
end
|
61
65
|
|
62
|
-
def self.user_agent=(user_agent)
|
63
|
-
@user_agent = user_agent
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.user_agent
|
67
|
-
@user_agent
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
66
|
def initialize(url)
|
72
67
|
self.uri = url
|
73
68
|
end
|
@@ -82,7 +77,7 @@ class HttpRequest
|
|
82
77
|
|
83
78
|
def request(type, options={})
|
84
79
|
user_agent = options[:user_agent] || HttpRequest.user_agent || 'HttpRequest'
|
85
|
-
timeout = (options[:timeout] || 10).to_i
|
80
|
+
timeout = (options[:timeout] || HttpRequest.timeout || 10).to_i
|
86
81
|
redirect_limit = options[:redirect_limit] || 5
|
87
82
|
output_file = options[:output_file]
|
88
83
|
content_max = options[:content_max]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 2
|
9
|
+
version: 1.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Peter Kieltyka
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-09 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|