parliament-ruby 1.0.0.pre5 → 1.0.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parliament/request/base_request.rb +8 -2
- data/lib/parliament/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: c20c1e1ecef5fa146b6209e261b51db12a088d84
|
4
|
+
data.tar.gz: 4d78672a08dfb72ccba0302752b90d15ade294a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5152616ce03a1bf39b73202423b7c36f0ac1360dbc1960895c95c4a7a9000bc6ce4b93354b4fe31d387215344d25bd8e18d8943abaf1e01a3f8ec9b1a5aa070d
|
7
|
+
data.tar.gz: b61512c2871d901c32679e6d9f5ff74c1ef61e75bdb3037bbe88830532d4c94aa6623c1df9dee10a6a9c2840983ab8d68cb9ca7c80eeedf0e5452ce12cb283d4
|
@@ -9,6 +9,9 @@ module Parliament
|
|
9
9
|
# @attr_reader [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
|
10
10
|
# @attr_reader [Hash] headers the headers being sent in the request.
|
11
11
|
class BaseRequest
|
12
|
+
TIMEOUT = 40.freeze
|
13
|
+
CONNECTTIMEOUT = 5.freeze
|
14
|
+
|
12
15
|
attr_reader :base_url, :headers, :query_params
|
13
16
|
# Creates a new instance of Parliament::Request::BaseRequest.
|
14
17
|
#
|
@@ -87,7 +90,7 @@ module Parliament
|
|
87
90
|
# @param [Hash] params (optional) additional URI encoded form values to be added to the URI.
|
88
91
|
#
|
89
92
|
# @return [Parliament::Response::BaseResponse] a Parliament::Response::BaseResponse object containing all of the data returned from the URL.
|
90
|
-
def get(params: nil)
|
93
|
+
def get(params: nil, timeout: TIMEOUT, connecttimeout: CONNECTTIMEOUT)
|
91
94
|
Typhoeus::Config.user_agent = 'Ruby'
|
92
95
|
|
93
96
|
uri_hash = separate_uri(query_url, @query_params, params)
|
@@ -97,6 +100,8 @@ module Parliament
|
|
97
100
|
method: :get,
|
98
101
|
params: uri_hash[:params],
|
99
102
|
headers: headers,
|
103
|
+
timeout: timeout,
|
104
|
+
connecttimeout: connecttimeout,
|
100
105
|
accept_encoding: 'gzip'
|
101
106
|
)
|
102
107
|
|
@@ -132,7 +137,7 @@ module Parliament
|
|
132
137
|
# @param [Integer] timeout (optional) a Net::HTTP.read_timeout value passed suring the post.
|
133
138
|
#
|
134
139
|
# @return [Parliament::Response::BaseResponse] a Parliament::Response::BaseResponse object containing all of the data returned from the URL.
|
135
|
-
def post(params: nil, body: nil, timeout:
|
140
|
+
def post(params: nil, body: nil, timeout: TIMEOUT, connecttimeout: CONNECTTIMEOUT)
|
136
141
|
Typhoeus::Config.user_agent = 'Ruby'
|
137
142
|
|
138
143
|
uri_hash = separate_uri(query_url, @query_params, params)
|
@@ -144,6 +149,7 @@ module Parliament
|
|
144
149
|
headers: headers.merge({ 'Content-Type' => 'application/json' }),
|
145
150
|
accept_encoding: 'gzip',
|
146
151
|
timeout: timeout,
|
152
|
+
connecttimeout: connecttimeout,
|
147
153
|
body: body
|
148
154
|
)
|
149
155
|
|
data/lib/parliament/version.rb
CHANGED