httpspec_simple 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/httpspec_simple/request.rb +5 -1
- data/lib/httpspec_simple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db33f5f3e41b2c4f616e953846eae5e2f00b48f0
|
4
|
+
data.tar.gz: 5426f6f894812dca68557c56bdf0afefe1eb8c96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e3eb83571fedc704b066e8557dcb602241bd915a302d93f2a83c119a10873b5d67775bf7ecea8fabaa60a815806a85f47f7c903101d6bfa13d821bcb6361f6a
|
7
|
+
data.tar.gz: 1dd470a183d6207a0f3190aa7e740db536d511cef82f96f6b7a9997a88ff3ce0edb23e49ceb1c2c449fd03f747355d6fe0aee2bd68f0771d14fdaca659d6d50e
|
data/README.md
CHANGED
@@ -65,6 +65,7 @@ option key | type | description
|
|
65
65
|
:retry | Integer | when the response code is {40x,50x} or the timeout occurs, retry request the specific times, default value is 0
|
66
66
|
:timeout | Integer | set to Net::HTTP's open_timeout and read_timeout
|
67
67
|
:headers | Hash | set to the request header
|
68
|
+
:basic_auth| Array | basic auth user and password(ex. `['user', 'passwd']`)
|
68
69
|
|
69
70
|
### base_url(prepend_string)
|
70
71
|
|
@@ -79,6 +80,7 @@ HttpspecSimple::Request.configure {|config|
|
|
79
80
|
config.retry = 3
|
80
81
|
config.timeout = 15
|
81
82
|
config.headers = {"user-agent" => "my-agent"}
|
83
|
+
config.basic_auth = ['user', 'passwd']
|
82
84
|
}
|
83
85
|
```
|
84
86
|
|
@@ -20,6 +20,9 @@ module HttpspecSimple
|
|
20
20
|
if (headers = opt[:headers] || Request.configuration.headers)
|
21
21
|
headers.each {|k, v| req[k] = v }
|
22
22
|
end
|
23
|
+
if (basic_auth = opt[:basic_auth] || Request.configuration.basic_auth)
|
24
|
+
req.basic_auth *basic_auth if Array === basic_auth
|
25
|
+
end
|
23
26
|
res = http.request(req)
|
24
27
|
raise RequestError.new if res.kind_of?(Net::HTTPClientError) or res.kind_of?(Net::HTTPServerError)
|
25
28
|
rescue open_timeout_error, read_timeout_error, RequestError
|
@@ -53,9 +56,10 @@ module HttpspecSimple
|
|
53
56
|
configuration.timeout = config.timeout
|
54
57
|
configuration.retry = config.retry
|
55
58
|
configuration.headers = config.headers
|
59
|
+
configuration.basic_auth = config.basic_auth
|
56
60
|
end
|
57
61
|
|
58
|
-
CONFIG_CLASS = Struct.new(:timeout, :retry, :headers)
|
62
|
+
CONFIG_CLASS = Struct.new(:timeout, :retry, :headers, :basic_auth)
|
59
63
|
|
60
64
|
def configuration
|
61
65
|
@config ||= reset_configuration
|