protocol-http 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/body/stream.rb +2 -2
- data/lib/protocol/http/body/streamable.rb +21 -25
- data/lib/protocol/http/body/writable.rb +13 -2
- data/lib/protocol/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b60538bc2a8f661748e6a70b92bf46932440e56f69e0cb22348fa14b0c59706f
|
4
|
+
data.tar.gz: 9a6629a169c0afff229eed8b660fc94c918cc9f0a953e5251b5f5f283e4e28fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 707f195fa9b7b2bfe446b6a2132dfe608570ec8fed696c8df558686e80da07c5026fac90941109dc7d743e3806daf8fdfb4d28ce051ba1412242b8fde4f45a99
|
7
|
+
data.tar.gz: 41a940d1dee93bc30d90fc0ae63fa34103d82379862c502a2ec11ec6f06521491e8eb6586ef43707957ff8ebc7f7016e893ad3b88751e93fdcf14976de8227d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -17,20 +17,12 @@ module Protocol
|
|
17
17
|
#
|
18
18
|
# When invoking `call(stream)`, the stream can be read from and written to, and closed. However, the stream is only guaranteed to be open for the duration of the `call(stream)` call. Once the method returns, the stream **should** be closed by the server.
|
19
19
|
module Streamable
|
20
|
-
def self.new(*arguments)
|
21
|
-
if arguments.size == 1
|
22
|
-
DeferredBody.new(*arguments)
|
23
|
-
else
|
24
|
-
Body.new(*arguments)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
20
|
def self.request(&block)
|
29
|
-
|
21
|
+
RequestBody.new(block)
|
30
22
|
end
|
31
23
|
|
32
24
|
def self.response(request, &block)
|
33
|
-
|
25
|
+
ResponseBody.new(block, request.body)
|
34
26
|
end
|
35
27
|
|
36
28
|
class Output
|
@@ -109,32 +101,37 @@ module Protocol
|
|
109
101
|
raise
|
110
102
|
end
|
111
103
|
|
112
|
-
|
113
|
-
def close(error = nil)
|
114
|
-
if output = @output
|
115
|
-
@output = nil
|
116
|
-
# Closing the output here may take some time, as it may need to finish handling the stream:
|
117
|
-
output.close(error)
|
118
|
-
end
|
119
|
-
|
104
|
+
def close_input(error = nil)
|
120
105
|
if input = @input
|
121
106
|
@input = nil
|
122
107
|
input.close(error)
|
123
108
|
end
|
124
109
|
end
|
110
|
+
|
111
|
+
def close_output(error = nil)
|
112
|
+
@output&.close(error)
|
113
|
+
end
|
125
114
|
end
|
126
115
|
|
127
|
-
# A
|
128
|
-
class
|
116
|
+
# A response body is used on the server side to generate the response body using a block.
|
117
|
+
class ResponseBody < Body
|
118
|
+
def close(error = nil)
|
119
|
+
# Close will be invoked when all the output is written.
|
120
|
+
self.close_output(error)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# A request body is used on the client side to generate the request body using a block.
|
125
|
+
#
|
126
|
+
# As the response body isn't available until the request is sent, the response body must be {stream}ed into the request body.
|
127
|
+
class RequestBody < Body
|
129
128
|
def initialize(block)
|
130
129
|
super(block, Writable.new)
|
131
130
|
end
|
132
131
|
|
133
|
-
# Closing a stream indicates we are no longer interested in reading from it, but in this case that does not mean that the output block is finished generating data.
|
134
132
|
def close(error = nil)
|
135
|
-
|
136
|
-
|
137
|
-
end
|
133
|
+
# Close will be invoked when all the input is read.
|
134
|
+
self.close_input(error)
|
138
135
|
end
|
139
136
|
|
140
137
|
# Stream the response body into the block's input.
|
@@ -143,7 +140,6 @@ module Protocol
|
|
143
140
|
@input.write(chunk)
|
144
141
|
end
|
145
142
|
rescue => error
|
146
|
-
raise
|
147
143
|
ensure
|
148
144
|
@input.close_write(error)
|
149
145
|
end
|
@@ -55,7 +55,14 @@ module Protocol
|
|
55
55
|
raise @error
|
56
56
|
end
|
57
57
|
|
58
|
-
@
|
58
|
+
# This operation may result in @error being set.
|
59
|
+
chunk = @queue.pop
|
60
|
+
|
61
|
+
if @error
|
62
|
+
raise @error
|
63
|
+
end
|
64
|
+
|
65
|
+
return chunk
|
59
66
|
end
|
60
67
|
|
61
68
|
# Write a single chunk to the body. Signal completion by calling `#finish`.
|
@@ -118,7 +125,11 @@ module Protocol
|
|
118
125
|
end
|
119
126
|
|
120
127
|
def inspect
|
121
|
-
|
128
|
+
if @error
|
129
|
+
"\#<#{self.class} #{@count} chunks written, #{status}, error=#{@error}>"
|
130
|
+
else
|
131
|
+
"\#<#{self.class} #{@count} chunks written, #{status}>"
|
132
|
+
end
|
122
133
|
end
|
123
134
|
|
124
135
|
private
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -47,7 +47,7 @@ cert_chain:
|
|
47
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
48
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
49
49
|
-----END CERTIFICATE-----
|
50
|
-
date: 2024-09-
|
50
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
51
51
|
dependencies: []
|
52
52
|
description:
|
53
53
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|