httpx 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes/1_1_4.md +1 -1
- data/doc/release_notes/1_1_5.md +12 -0
- data/lib/httpx/adapters/webmock.rb +5 -6
- data/lib/httpx/plugins/grpc/call.rb +2 -3
- data/lib/httpx/plugins/grpc/grpc_encoding.rb +1 -0
- data/lib/httpx/plugins/stream.rb +8 -3
- data/lib/httpx/request.rb +14 -3
- data/lib/httpx/response.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- data/sig/plugins/stream.rbs +24 -22
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d95b9f470645015a3308ade4ab2349375eddd0598f6919fbf063d4feba61926c
|
4
|
+
data.tar.gz: 95518fc5601eb0ba9a22e13814f9f0a339addca71e94c33122ed211780049ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729bfc7fc5888f6872ecf9dfdcaefa6df68ba96b705cf1ccd1e8b9b866d25bf2c3081577b3c1828b99556009fc686c0705eb30dcb6fd5f2a3fb951128e0c621e
|
7
|
+
data.tar.gz: 1173ae3cd242caf251c099e14db090efc3ac3524d8e3f63e04c331f2938a6d747c9874999d79dbc4790894fc8c447c900740235a62cb0376f2b124dad3674acc
|
data/doc/release_notes/1_1_4.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# 1.1.4
|
2
2
|
|
3
|
-
##
|
3
|
+
## bugfixes
|
4
4
|
|
5
5
|
* datadog adapter: use `Gem::Version` to invoke the correct configuration API.
|
6
6
|
* stream plugin: do not preempt request enqueuing (this was making integration with the `:follow_redirects` plugin fail when set up with `webmock`).
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# 1.1.5
|
2
|
+
|
3
|
+
## improvements
|
4
|
+
|
5
|
+
* pattern matching support for responses has been backported to ruby 2.7 as well.
|
6
|
+
|
7
|
+
## bugfixes
|
8
|
+
|
9
|
+
* `stream` plugin: fix for `HTTPX::StreamResponse#each_line` not yielding the last line of the payload when not delimiter-terminated.
|
10
|
+
* `stream` plugin: fix `webmock` adapter integration when methods calls would happen in the `HTTPX::StreamResponse#each` block.
|
11
|
+
* `stream` plugin: fix `:follow_redirects` plugin integration which was caching the redirect response and using it for method calls inside the `HTTPX::StreamResponse#each` block.
|
12
|
+
* "103 early hints" responses will be ignored when processing the response (it was causing the response returned by sesssions to hold its headers, instead of the following 200 response, while keeping the 200 response body).
|
@@ -38,12 +38,10 @@ module WebMock
|
|
38
38
|
|
39
39
|
return build_error_response(request, webmock_response.exception) if webmock_response.exception
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
response << webmock_response.body.dup
|
46
|
-
response
|
41
|
+
request.options.response_class.new(request,
|
42
|
+
webmock_response.status[0],
|
43
|
+
"2.0",
|
44
|
+
webmock_response.headers)
|
47
45
|
end
|
48
46
|
|
49
47
|
def build_error_response(request, exception)
|
@@ -90,6 +88,7 @@ module WebMock
|
|
90
88
|
log { "mocking #{request.uri} with #{mock_response.inspect}" }
|
91
89
|
request.response = response
|
92
90
|
request.emit(:response, response)
|
91
|
+
response << mock_response.body.dup unless response.is_a?(HTTPX::ErrorResponse)
|
93
92
|
elsif WebMock.net_connect_allowed?(request_signature.uri)
|
94
93
|
if WebMock::CallbackRegistry.any_callbacks?
|
95
94
|
request.on(:response) do |resp|
|
@@ -11,6 +11,7 @@ module HTTPX
|
|
11
11
|
@response = response
|
12
12
|
@decoder = ->(z) { z }
|
13
13
|
@consumed = false
|
14
|
+
@grpc_response = nil
|
14
15
|
end
|
15
16
|
|
16
17
|
def inspect
|
@@ -34,9 +35,7 @@ module HTTPX
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def grpc_response
|
37
|
-
|
38
|
-
|
39
|
-
@grpc_response = if @response.respond_to?(:each)
|
38
|
+
@grpc_response ||= if @response.respond_to?(:each)
|
40
39
|
Enumerator.new do |y|
|
41
40
|
Message.stream(@response).each do |message|
|
42
41
|
y << @decoder.call(message)
|
data/lib/httpx/plugins/stream.rb
CHANGED
@@ -5,6 +5,7 @@ module HTTPX
|
|
5
5
|
def initialize(request, session)
|
6
6
|
@request = request
|
7
7
|
@session = session
|
8
|
+
@response = nil
|
8
9
|
end
|
9
10
|
|
10
11
|
def each(&block)
|
@@ -25,7 +26,7 @@ module HTTPX
|
|
25
26
|
def each_line
|
26
27
|
return enum_for(__method__) unless block_given?
|
27
28
|
|
28
|
-
line =
|
29
|
+
line = "".b
|
29
30
|
|
30
31
|
each do |chunk|
|
31
32
|
line << chunk
|
@@ -36,6 +37,8 @@ module HTTPX
|
|
36
37
|
line = line.byteslice(idx + 1..-1)
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
yield line unless line.empty?
|
39
42
|
end
|
40
43
|
|
41
44
|
# This is a ghost method. It's to be used ONLY internally, when processing streams
|
@@ -58,8 +61,10 @@ module HTTPX
|
|
58
61
|
private
|
59
62
|
|
60
63
|
def response
|
61
|
-
@response
|
62
|
-
|
64
|
+
return @response if @response
|
65
|
+
|
66
|
+
@request.response || begin
|
67
|
+
@response = @session.request(@request)
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
data/lib/httpx/request.rb
CHANGED
@@ -119,10 +119,21 @@ module HTTPX
|
|
119
119
|
def response=(response)
|
120
120
|
return unless response
|
121
121
|
|
122
|
-
if response.is_a?(Response) && response.status
|
123
|
-
|
124
|
-
|
122
|
+
if response.is_a?(Response) && response.status < 200
|
123
|
+
# deal with informational responses
|
124
|
+
|
125
|
+
if response.status == 100 && @headers.key?("expect")
|
126
|
+
@informational_status = response.status
|
127
|
+
return
|
128
|
+
end
|
129
|
+
|
130
|
+
if response.status >= 103
|
131
|
+
# 103 Early Hints advertises resources in document to browsers.
|
132
|
+
# not very relevant for an HTTP client, discard.
|
133
|
+
return
|
134
|
+
end
|
125
135
|
end
|
136
|
+
|
126
137
|
@response = response
|
127
138
|
|
128
139
|
emit(:response_started, response)
|
data/lib/httpx/response.rb
CHANGED
data/lib/httpx/version.rb
CHANGED
data/sig/plugins/stream.rbs
CHANGED
@@ -1,26 +1,4 @@
|
|
1
1
|
module HTTPX
|
2
|
-
class StreamResponse
|
3
|
-
include _ToS
|
4
|
-
|
5
|
-
@request: Request & RequestMethods
|
6
|
-
@session: sessionStream
|
7
|
-
@on_chunk: ^(String) -> void | nil
|
8
|
-
|
9
|
-
def each: () { (String) -> void } -> void
|
10
|
-
| () -> Enumerable[String]
|
11
|
-
|
12
|
-
def each_line: () { (String) -> void } -> void
|
13
|
-
| () -> Enumerable[String]
|
14
|
-
|
15
|
-
def on_chunk: (string) -> void
|
16
|
-
|
17
|
-
def initialize: (Request, Session) -> void
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def response: () -> response
|
22
|
-
end
|
23
|
-
|
24
2
|
module Plugins
|
25
3
|
module Stream
|
26
4
|
module InstanceMethods
|
@@ -42,4 +20,28 @@ module HTTPX
|
|
42
20
|
|
43
21
|
type sessionStream = Session & Stream::InstanceMethods
|
44
22
|
end
|
23
|
+
|
24
|
+
class StreamResponse
|
25
|
+
include _ToS
|
26
|
+
|
27
|
+
type streamRequest = Request & Plugins::Stream::RequestMethods
|
28
|
+
|
29
|
+
@request: streamRequest
|
30
|
+
@session: Plugins::sessionStream
|
31
|
+
@on_chunk: ^(String) -> void | nil
|
32
|
+
|
33
|
+
def each: () { (String) -> void } -> void
|
34
|
+
| () -> Enumerable[String]
|
35
|
+
|
36
|
+
def each_line: () { (String) -> void } -> void
|
37
|
+
| () -> Enumerable[String]
|
38
|
+
|
39
|
+
def on_chunk: (string) -> void
|
40
|
+
|
41
|
+
def initialize: (streamRequest, Plugins::sessionStream) -> void
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def response: () -> response
|
46
|
+
end
|
45
47
|
end
|
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: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -136,6 +136,7 @@ extra_rdoc_files:
|
|
136
136
|
- doc/release_notes/1_1_2.md
|
137
137
|
- doc/release_notes/1_1_3.md
|
138
138
|
- doc/release_notes/1_1_4.md
|
139
|
+
- doc/release_notes/1_1_5.md
|
139
140
|
files:
|
140
141
|
- LICENSE.txt
|
141
142
|
- README.md
|
@@ -243,6 +244,7 @@ files:
|
|
243
244
|
- doc/release_notes/1_1_2.md
|
244
245
|
- doc/release_notes/1_1_3.md
|
245
246
|
- doc/release_notes/1_1_4.md
|
247
|
+
- doc/release_notes/1_1_5.md
|
246
248
|
- lib/httpx.rb
|
247
249
|
- lib/httpx/adapters/datadog.rb
|
248
250
|
- lib/httpx/adapters/faraday.rb
|