ezclient 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +4 -0
- data/README.md +1 -2
- data/ezclient.gemspec +1 -1
- data/gemfiles/http3.gemfile +6 -0
- data/gemfiles/http4.gemfile +6 -0
- data/lib/ezclient/http_patch.rb +32 -0
- data/lib/ezclient/request.rb +15 -1
- data/lib/ezclient/version.rb +1 -1
- data/lib/ezclient.rb +1 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7894472c0e1703cc7917dec4725830f0ec9f39cdde75b10e8e62131f1cc72376
|
4
|
+
data.tar.gz: c1ff86649d20f2b7f3787083bdfcd10b3817086c74ff876c7b2b8ccca2759a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807d13903a58fc3d39f95ca8b620cd5a578934d8925c09484f89779d283d18733d5b683955c30b6a9c95de6ee18cbef1d099c30fdb4ee7298dbd4d644e7e8cd9
|
7
|
+
data.tar.gz: d49b93cc0bf2d93febb1bbed745e332431e709500858565be75bcaec7a608f1b9c36371bff3a5092801659ecb4713f7cd8164935f765056ef429de0b8b6d23d6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
EzClient is [HTTP gem](https://github.com/httprb/http) wrapper for easy persistent connections and more.
|
3
3
|
|
4
4
|
## Installation
|
5
|
-
Add this
|
5
|
+
Add this line to your application's Gemfile:
|
6
6
|
|
7
7
|
```ruby
|
8
8
|
gem "ezclient"
|
9
|
-
gem "http", github: "httprb/http" # version 3 is not supported for now
|
10
9
|
```
|
11
10
|
|
12
11
|
## Usage
|
data/ezclient.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency "http", ">=
|
20
|
+
spec.add_runtime_dependency "http", ">= 3"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "coveralls"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
unless HTTP::Client.instance_methods.include?(:build_request)
|
4
|
+
# Backport of https://github.com/httprb/http/pull/458 for HTTP v3
|
5
|
+
class HTTP::Client
|
6
|
+
def build_request(verb, uri, opts = {})
|
7
|
+
opts = @default_options.merge(opts)
|
8
|
+
uri = make_request_uri(uri, opts)
|
9
|
+
headers = make_request_headers(opts)
|
10
|
+
body = make_request_body(opts, headers)
|
11
|
+
proxy = opts.proxy
|
12
|
+
|
13
|
+
HTTP::Request.new(
|
14
|
+
verb: verb,
|
15
|
+
uri: uri,
|
16
|
+
headers: headers,
|
17
|
+
proxy: proxy,
|
18
|
+
body: body,
|
19
|
+
auto_deflate: opts.feature(:auto_deflate),
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
unless HTTP::Request::Body.instance_methods.include?(:source)
|
26
|
+
# Backport for HTTP v3
|
27
|
+
class HTTP::Request::Body
|
28
|
+
def source
|
29
|
+
@body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ezclient/request.rb
CHANGED
@@ -85,7 +85,7 @@ class EzClient::Request
|
|
85
85
|
# Only used to build proper HTTP::Request and HTTP::Options instances
|
86
86
|
@http_client ||= begin
|
87
87
|
http_client = client.dup
|
88
|
-
http_client = http_client
|
88
|
+
http_client = set_timeout(http_client)
|
89
89
|
http_client = http_client.basic_auth(basic_auth) if basic_auth
|
90
90
|
http_client
|
91
91
|
end
|
@@ -149,6 +149,20 @@ class EzClient::Request
|
|
149
149
|
headers
|
150
150
|
end
|
151
151
|
|
152
|
+
def set_timeout(client)
|
153
|
+
return client unless timeout
|
154
|
+
|
155
|
+
timeout_args =
|
156
|
+
# for HTTP v3
|
157
|
+
if HTTP::Timeout::Global.ancestors.include?(HTTP::Timeout::PerOperation)
|
158
|
+
[:global, read: timeout]
|
159
|
+
else
|
160
|
+
[timeout]
|
161
|
+
end
|
162
|
+
|
163
|
+
client.timeout(*timeout_args)
|
164
|
+
end
|
165
|
+
|
152
166
|
def basic_auth
|
153
167
|
@basic_auth ||= begin
|
154
168
|
case options[:basic_auth]
|
data/lib/ezclient/version.rb
CHANGED
data/lib/ezclient.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Smirnov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,10 +152,13 @@ files:
|
|
152
152
|
- README.md
|
153
153
|
- Rakefile
|
154
154
|
- ezclient.gemspec
|
155
|
+
- gemfiles/http3.gemfile
|
156
|
+
- gemfiles/http4.gemfile
|
155
157
|
- lib/ezclient.rb
|
156
158
|
- lib/ezclient/check_options.rb
|
157
159
|
- lib/ezclient/client.rb
|
158
160
|
- lib/ezclient/errors.rb
|
161
|
+
- lib/ezclient/http_patch.rb
|
159
162
|
- lib/ezclient/request.rb
|
160
163
|
- lib/ezclient/response.rb
|
161
164
|
- lib/ezclient/version.rb
|