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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1d01285c37f91d697e015646a6ed3efecfe08c8db97d94c636e27cec44497be
4
- data.tar.gz: 1f494626f6f7fb446dc23e37eadcc0e8fae493c2701dabc796d108342b8dba58
3
+ metadata.gz: febab259d00ab223310ce97b93c2833a3a17e4593c5072d34fa06d502c16a928
4
+ data.tar.gz: 75bc5e802779efd48411d87f0261dd57e8ae9a3061efc85351102614816af17c
5
5
  SHA512:
6
- metadata.gz: 7dc7cc8c0df3b688c30ee1b13a6e2178a84a0ea5bfc66e6e50af9b36c239224c94abe11237d2f5d6310df75eb08a56ff56787c39cb33aebd28c85808a6cadeea
7
- data.tar.gz: c9865d6691c36ebc6d8c5d3614317256831b55718d6655f90cb0843c60bed0cc75e02c96dfdf6005c0637c3cd65c70368dbd69091df41d026e372c41cba38a4b
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
- Streaming = ::Protocol::HTTP::Body::Streamable::ResponseBody
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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.21.0"
8
+ VERSION = "0.21.1"
9
9
  end
10
10
  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
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.21.1
4
+
5
+ - Fix missing `body#close` for streaming bodies.
6
+
3
7
  ## v0.21.0
4
8
 
5
9
  - For the purpose of constructing the rack request environment, trailers are ignored.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file