protocol-rack 0.21.0 → 0.21.1
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/rack/body/enumerable.rb +7 -5
- data/lib/protocol/rack/body/streaming.rb +31 -1
- data/lib/protocol/rack/version.rb +1 -1
- data/readme.md +4 -4
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: febab259d00ab223310ce97b93c2833a3a17e4593c5072d34fa06d502c16a928
|
|
4
|
+
data.tar.gz: 75bc5e802779efd48411d87f0261dd57e8ae9a3061efc85351102614816af17c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e6c9abca60e25c7d31c7ddc08a98036f77f27ef73e9c1fd2d415712a2615e79c2bb3272a0e6f74afdd94c06968e8482640545f9f0f18836ec744a941bc672ba
|
|
7
|
+
data.tar.gz: 49c0b5eed90e4afe2eb60903264080963cb70bde3932004e806abf0fcc0e9e15516df3cdb2ef29fa59e439bb666326a4b644d4db989fadb0e762d07f16821f80
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -69,13 +69,15 @@ module Protocol
|
|
|
69
69
|
#
|
|
70
70
|
# @parameter error [Exception] Optional error that occurred during processing.
|
|
71
71
|
def close(error = nil)
|
|
72
|
-
if @body and @body.respond_to?(:close)
|
|
73
|
-
@body.close
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
@body = nil
|
|
77
72
|
@chunks = nil
|
|
78
73
|
|
|
74
|
+
if body = @body
|
|
75
|
+
@body = nil
|
|
76
|
+
if body.respond_to?(:close)
|
|
77
|
+
body.close
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
79
81
|
super
|
|
80
82
|
end
|
|
81
83
|
|
|
@@ -8,7 +8,37 @@ require "protocol/http/body/streamable"
|
|
|
8
8
|
module Protocol
|
|
9
9
|
module Rack
|
|
10
10
|
module Body
|
|
11
|
-
|
|
11
|
+
# Wraps a Rack streaming response body.
|
|
12
|
+
# The body must be callable and accept a stream argument.
|
|
13
|
+
# This is typically used for Rack hijack responses or bodies wrapped in `Rack::BodyProxy`.
|
|
14
|
+
# When closed, this class ensures the wrapped body's `close` method is called if it exists.
|
|
15
|
+
class Streaming < ::Protocol::HTTP::Body::Streamable::ResponseBody
|
|
16
|
+
# Initialize the streaming body wrapper.
|
|
17
|
+
#
|
|
18
|
+
# @parameter body [Object] A callable object that accepts a stream argument, such as a Proc or an object that responds to `call`. May optionally respond to `close` for cleanup (e.g., `Rack::BodyProxy`).
|
|
19
|
+
# @parameter input [Protocol::HTTP::Body::Readable | Nil] Optional input body for bi-directional streaming.
|
|
20
|
+
def initialize(body, input = nil)
|
|
21
|
+
@body = body
|
|
22
|
+
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Close the streaming body and clean up resources.
|
|
27
|
+
# If the wrapped body responds to `close`, it will be called to allow proper cleanup.
|
|
28
|
+
# This ensures that `Rack::BodyProxy` cleanup callbacks are invoked correctly.
|
|
29
|
+
#
|
|
30
|
+
# @parameter error [Exception | Nil] Optional error that caused the stream to close.
|
|
31
|
+
def close(error = nil)
|
|
32
|
+
if body = @body
|
|
33
|
+
@body = nil
|
|
34
|
+
if body.respond_to?(:close)
|
|
35
|
+
body.close
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
end
|
|
12
42
|
end
|
|
13
43
|
end
|
|
14
44
|
end
|
data/readme.md
CHANGED
|
@@ -21,6 +21,10 @@ Please see the [project documentation](https://socketry.github.io/protocol-rack/
|
|
|
21
21
|
|
|
22
22
|
Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
|
|
23
23
|
|
|
24
|
+
### v0.21.1
|
|
25
|
+
|
|
26
|
+
- Fix missing `body#close` for streaming bodies.
|
|
27
|
+
|
|
24
28
|
### v0.21.0
|
|
25
29
|
|
|
26
30
|
- For the purpose of constructing the rack request environment, trailers are ignored.
|
|
@@ -60,10 +64,6 @@ Please see the [project releases](https://socketry.github.io/protocol-rack/relea
|
|
|
60
64
|
- `Protocol::Rack::Input#rewind` now works when the entire input is already read.
|
|
61
65
|
- `Protocol::Rack::Adapter::Rack2` has stricter validation of the application response.
|
|
62
66
|
|
|
63
|
-
### v0.12.0
|
|
64
|
-
|
|
65
|
-
- Ignore (and close) response bodies for status codes that don't allow them.
|
|
66
|
-
|
|
67
67
|
## Contributing
|
|
68
68
|
|
|
69
69
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|