httpx 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/doc/release_notes/0_9_0.md +38 -0
- data/lib/httpx/chainable.rb +2 -3
- data/lib/httpx/extensions.rb +1 -1
- data/lib/httpx/headers.rb +1 -1
- data/lib/httpx/options.rb +3 -1
- data/lib/httpx/response.rb +0 -2
- data/lib/httpx/selector.rb +1 -1
- data/lib/httpx/session.rb +14 -12
- data/lib/httpx/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e15b3e81842118829ecc251093ce5e80ad0c82dada2c7b2588004b2bf7313f63
|
4
|
+
data.tar.gz: 9d4efcb47f0c269f2c5b9a3c950fe8069c3b76ffb2f9624b557d29a702704712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fbd146e351da8f603c8b00c236d92c7a2a3c383296736f271c88b0ac310086adf0127af7b630e9087ec45c4a22494128b2efafdb2592de43df4aae4a68ef1f3
|
7
|
+
data.tar.gz: eecb817b76bc0f217b728c7e862f73758e4b2db9c6a943311e0c7d10d8e7fe6bfa8e56a7c0d4593158fb605927813a1e720ec85a9d7e70aae8ecce015f5da647
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/httpx.svg)](http://rubygems.org/gems/httpx)
|
4
4
|
[![pipeline status](https://gitlab.com/honeyryderchuck/httpx/badges/master/pipeline.svg)](https://gitlab.com/honeyryderchuck/httpx/commits/master)
|
5
|
-
[![coverage report](https://gitlab.com/honeyryderchuck/httpx/badges/master/coverage.svg)](https://honeyryderchuck.gitlab.io/httpx/coverage/#_AllFiles)
|
5
|
+
[![coverage report](https://gitlab.com/honeyryderchuck/httpx/badges/master/coverage.svg?job=coverage)](https://honeyryderchuck.gitlab.io/httpx/coverage/#_AllFiles)
|
6
6
|
|
7
7
|
HTTPX is an HTTP client library for the Ruby programming language.
|
8
8
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# 0.9.0
|
2
|
+
|
3
|
+
## Features
|
4
|
+
|
5
|
+
### Multiple requests with specific options
|
6
|
+
|
7
|
+
You can now pass a third element to the "request element" of an array to `.request`.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
requests = [
|
11
|
+
[:post, "https://url/post", { form: { foo: "bar" } }],
|
12
|
+
[:post, "https://url/post", { form: { foo: "bar2" } }]
|
13
|
+
]
|
14
|
+
HTTPX.request(requests)
|
15
|
+
# or, if you want to pass options common to all requests
|
16
|
+
HTTPX.request(requests, max_concurrent_requests: 1)
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
### HTTPX::Session#build_request
|
21
|
+
|
22
|
+
`HTTPX::Session::build_request` is now public API from a session. You can now build requests before you send them. These request objects are still considered somewhat "internal", so consider them immutable and **do not rely on its API**. Just pass them forward.
|
23
|
+
|
24
|
+
Note: this API is only available for instantiated session, so there is no `HTTPX.build_request`.
|
25
|
+
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
|
29
|
+
HTTPX.wrap do |http|
|
30
|
+
requests = [
|
31
|
+
http.build_request(:post, "https://url/post", { form: { foo: "bar" } }),
|
32
|
+
http.build_request(:post, "https://url/post", { form: { foo: "bar2" } })
|
33
|
+
]
|
34
|
+
http.request(requests)
|
35
|
+
# or, if you want to pass options common to all requests
|
36
|
+
http.request(requests, max_concurrent_requests: 1)
|
37
|
+
end
|
38
|
+
```
|
data/lib/httpx/chainable.rb
CHANGED
@@ -10,8 +10,8 @@ module HTTPX
|
|
10
10
|
MOD
|
11
11
|
end
|
12
12
|
|
13
|
-
def request(
|
14
|
-
branch(default_options).request(
|
13
|
+
def request(*args, **options)
|
14
|
+
branch(default_options).request(*args, **options)
|
15
15
|
end
|
16
16
|
|
17
17
|
# :nocov:
|
@@ -59,7 +59,6 @@ module HTTPX
|
|
59
59
|
@options || Options.new
|
60
60
|
end
|
61
61
|
|
62
|
-
# :nodoc:
|
63
62
|
def branch(options, &blk)
|
64
63
|
return self.class.new(options, &blk) if is_a?(Session)
|
65
64
|
|
data/lib/httpx/extensions.rb
CHANGED
@@ -11,7 +11,7 @@ module HTTPX
|
|
11
11
|
#
|
12
12
|
# Why not using Refinements? Because they don't work for Method (tested with ruby 2.1.9).
|
13
13
|
#
|
14
|
-
module CurryMethods
|
14
|
+
module CurryMethods
|
15
15
|
# Backport for the Method#curry method, which is part of ruby core since 2.2 .
|
16
16
|
#
|
17
17
|
def curry(*args)
|
data/lib/httpx/headers.rb
CHANGED
data/lib/httpx/options.rb
CHANGED
data/lib/httpx/response.rb
CHANGED
@@ -239,13 +239,11 @@ module HTTPX
|
|
239
239
|
|
240
240
|
private
|
241
241
|
|
242
|
-
# :nodoc:
|
243
242
|
def mime_type(str)
|
244
243
|
m = str.to_s[MIME_TYPE_RE, 1]
|
245
244
|
m && m.strip.downcase
|
246
245
|
end
|
247
246
|
|
248
|
-
# :nodoc:
|
249
247
|
def charset(str)
|
250
248
|
m = str.to_s[CHARSET_RE, 1]
|
251
249
|
m && m.strip.delete('"')
|
data/lib/httpx/selector.rb
CHANGED
data/lib/httpx/session.rb
CHANGED
@@ -5,7 +5,9 @@ module HTTPX
|
|
5
5
|
include Loggable
|
6
6
|
include Chainable
|
7
7
|
|
8
|
-
|
8
|
+
EMPTY_HASH = {}.freeze
|
9
|
+
|
10
|
+
def initialize(options = EMPTY_HASH, &blk)
|
9
11
|
@options = self.class.default_options.merge(options)
|
10
12
|
@responses = {}
|
11
13
|
@persistent = @options.persistent
|
@@ -29,13 +31,21 @@ module HTTPX
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def request(*args, **options)
|
32
|
-
requests = build_requests(*args, options)
|
34
|
+
requests = args.first.is_a?(Request) ? args : build_requests(*args, options)
|
33
35
|
responses = send_requests(*requests, options)
|
34
36
|
return responses.first if responses.size == 1
|
35
37
|
|
36
38
|
responses
|
37
39
|
end
|
38
40
|
|
41
|
+
def build_request(verb, uri, options = EMPTY_HASH)
|
42
|
+
rklass = @options.request_class
|
43
|
+
request = rklass.new(verb, uri, @options.merge(options).merge(persistent: @persistent))
|
44
|
+
request.on(:response, &method(:on_response).curry[request])
|
45
|
+
request.on(:promise, &method(:on_promise))
|
46
|
+
request
|
47
|
+
end
|
48
|
+
|
39
49
|
private
|
40
50
|
|
41
51
|
def pool
|
@@ -122,8 +132,8 @@ module HTTPX
|
|
122
132
|
requests = case args.size
|
123
133
|
when 1
|
124
134
|
reqs = args.first
|
125
|
-
reqs.map do |verb, uri|
|
126
|
-
build_request(verb, uri, request_options)
|
135
|
+
reqs.map do |verb, uri, opts = EMPTY_HASH|
|
136
|
+
build_request(verb, uri, request_options.merge(opts))
|
127
137
|
end
|
128
138
|
when 2, 3
|
129
139
|
verb, uris = args
|
@@ -195,14 +205,6 @@ module HTTPX
|
|
195
205
|
end
|
196
206
|
end
|
197
207
|
|
198
|
-
def build_request(verb, uri, options)
|
199
|
-
rklass = @options.request_class
|
200
|
-
request = rklass.new(verb, uri, @options.merge(options).merge(persistent: @persistent))
|
201
|
-
request.on(:response, &method(:on_response).curry[request])
|
202
|
-
request.on(:promise, &method(:on_promise))
|
203
|
-
request
|
204
|
-
end
|
205
|
-
|
206
208
|
@default_options = Options.new
|
207
209
|
@default_options.freeze
|
208
210
|
@plugins = []
|
data/lib/httpx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -90,6 +90,7 @@ extra_rdoc_files:
|
|
90
90
|
- doc/release_notes/0_6_0.md
|
91
91
|
- doc/release_notes/0_8_2.md
|
92
92
|
- doc/release_notes/0_6_4.md
|
93
|
+
- doc/release_notes/0_9_0.md
|
93
94
|
- doc/release_notes/0_6_3.md
|
94
95
|
- doc/release_notes/0_8_1.md
|
95
96
|
- doc/release_notes/0_5_0.md
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- doc/release_notes/0_8_0.md
|
136
137
|
- doc/release_notes/0_8_1.md
|
137
138
|
- doc/release_notes/0_8_2.md
|
139
|
+
- doc/release_notes/0_9_0.md
|
138
140
|
- lib/httpx.rb
|
139
141
|
- lib/httpx/adapters/faraday.rb
|
140
142
|
- lib/httpx/altsvc.rb
|
@@ -203,7 +205,7 @@ metadata:
|
|
203
205
|
changelog_uri: https://honeyryderchuck.gitlab.io/httpx/#release-notes
|
204
206
|
documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
|
205
207
|
source_code_uri: https://gitlab.com/honeyryderchuck/httpx
|
206
|
-
post_install_message:
|
208
|
+
post_install_message:
|
207
209
|
rdoc_options: []
|
208
210
|
require_paths:
|
209
211
|
- lib
|
@@ -219,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
221
|
version: '0'
|
220
222
|
requirements: []
|
221
223
|
rubygems_version: 3.1.2
|
222
|
-
signing_key:
|
224
|
+
signing_key:
|
223
225
|
specification_version: 4
|
224
226
|
summary: HTTPX, to the future, and beyond
|
225
227
|
test_files: []
|