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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a47b69da7c2f5656023f20e39b79bb2e069634a
4
- data.tar.gz: e74966e7e67152725d5491d8e33f4a39b441f6b0
3
+ metadata.gz: db33f5f3e41b2c4f616e953846eae5e2f00b48f0
4
+ data.tar.gz: 5426f6f894812dca68557c56bdf0afefe1eb8c96
5
5
  SHA512:
6
- metadata.gz: 752d6eb3c09df394e4e67bb1f23f515d0903960a0f129a1a1635059c2ac75ddf2bc523459ce2dd7323a27ae9f2f8bff12c60daffeafa145a3c04daccb58a943d
7
- data.tar.gz: 5598cd7768922a731bcc011c55a650436433f929786324598772980f3690caeb510794142250a13683771ac10a28f737a48c6de10a00349e0d6a64d37ab2ec8f
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
@@ -1,3 +1,3 @@
1
1
  module HttpspecSimple
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpspec_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koji NAKAMURA