protocol-http 0.68.0 → 0.69.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3428056fc04e13182008e3f50f457e9b63b688c887c528e4afc8606e447c620
4
- data.tar.gz: e1c5a2b380ff917013e2cdf1e8c6bda8a4995d3850fa960bf933177ebc518295
3
+ metadata.gz: e15c95aaaa592e283652205e025ad4473e3f082865506604799bb8eaadf06368
4
+ data.tar.gz: 10b0bf633c92acbec2fb96a70e5693060cab025e2df7ea45aaad410ba9c7afad
5
5
  SHA512:
6
- metadata.gz: 6a0554e8f574add7c898db51ecccce34def388ba266c648487ef6f538c0db0d99966f2ee0c15d1462088587e29676ddf94f07531c257326442320cd2d30ab157
7
- data.tar.gz: 4acaacb6205bc8dcdd5be3ed7a5993dff2012b7ac61ad3a8a1e6ea607c1f01b481218ef3b60efa6bc34a9a86f982077aabe9ec7bafe43b8659b9272cb1e11d6a
6
+ metadata.gz: 99165410a3df8b9efef707e17e1ea31befa3510a65c111a77d17270ffb9167f15d36d6bc64512ee2d7aea2ff3cf5087379e7826ce54595087f89d227eb42f9b6
7
+ data.tar.gz: 297e0e29550b333cfa5f35005263e9762ff8afc64c6ca9e1f76ca1fcfb0c0b9ea3a7364f81f8349aced4b9aa018d7892b5362863896d0827f0d4daec9fd0c648
checksums.yaml.gz.sig CHANGED
Binary file
@@ -4,6 +4,8 @@
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2023, by Bruno Sutic.
6
6
 
7
+ require_relative "stream"
8
+
7
9
  module Protocol
8
10
  module HTTP
9
11
  module Body
@@ -186,6 +188,12 @@ module Protocol
186
188
  def to_json(...)
187
189
  as_json.to_json(...)
188
190
  end
191
+
192
+ # Return an IO-compatible stream for reading this body.
193
+ # @returns [Stream] The IO-compatible stream adapter.
194
+ def to_io
195
+ return Stream.new(self)
196
+ end
189
197
  end
190
198
  end
191
199
  end
@@ -5,8 +5,6 @@
5
5
  # Copyright, 2023, by Genki Takiuchi.
6
6
  # Copyright, 2025, by William T. Nelson.
7
7
 
8
- require_relative "buffered"
9
-
10
8
  module Protocol
11
9
  module HTTP
12
10
  module Body
@@ -17,13 +15,15 @@ module Protocol
17
15
 
18
16
  # Initialize the stream with the given input and output.
19
17
  #
20
- # @parameter input [Readable] The input stream.
21
- # @parameter output [Writable] The output stream.
22
- def initialize(input = nil, output = Buffered.new)
18
+ # @parameter input [Readable | Nil] The input stream.
19
+ # @parameter output [Writable | Nil] The output stream.
20
+ def initialize(input = nil, output = nil)
23
21
  @input = input
24
22
  @output = output
25
23
 
26
- raise ArgumentError, "Non-writable output!" unless output.respond_to?(:write)
24
+ if @output
25
+ raise ArgumentError, "Non-writable output!" unless output.respond_to?(:write)
26
+ end
27
27
 
28
28
  # Will hold remaining data in `#read`.
29
29
  @buffer = nil
@@ -32,10 +32,10 @@ module Protocol
32
32
  @closed_read = false
33
33
  end
34
34
 
35
- # @attribute [Readable] The input stream.
35
+ # @attribute [Readable | Nil] The input stream.
36
36
  attr :input
37
37
 
38
- # @attribute [Writable] The output stream.
38
+ # @attribute [Writable | Nil] The output stream.
39
39
  attr :output
40
40
 
41
41
  # This provides a read-only interface for data, which is surprisingly tricky to implement correctly.
@@ -409,7 +409,11 @@ module Protocol
409
409
 
410
410
  # @returns [Boolean] Whether there are any output chunks remaining.
411
411
  def empty?
412
- @output.empty?
412
+ if @output
413
+ return @output.empty?
414
+ else
415
+ return true
416
+ end
413
417
  end
414
418
 
415
419
  private
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.68.0"
8
+ VERSION = "0.69.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -30,6 +30,11 @@ Please see the [project documentation](https://socketry.github.io/protocol-http/
30
30
 
31
31
  Please see the [project releases](https://socketry.github.io/protocol-http/releases/index) for all releases.
32
32
 
33
+ ### v0.69.0
34
+
35
+ - Add `Protocol::HTTP::Body::Readable#to_io` for obtaining an IO-compatible stream adapter.
36
+ - Avoid creating an implicit buffered output for `Protocol::HTTP::Body::Stream`.
37
+
33
38
  ### v0.68.0
34
39
 
35
40
  - Add HTTP status descriptions.
@@ -67,11 +72,6 @@ Please see the [project releases](https://socketry.github.io/protocol-http/relea
67
72
 
68
73
  - Expose `Protocol::HTTP::Body::Writable#count` attribute to provide access to the number of chunks written to the body.
69
74
 
70
- ### v0.59.0
71
-
72
- - Introduce `Protocol::HTTP::Middleware.load` method for loading middleware applications from files.
73
- - Prevent `ZLib::BufError` when deflating empty chunks by skipping deflation for empty chunks.
74
-
75
75
  ## See Also
76
76
 
77
77
  - [protocol-http1](https://github.com/socketry/protocol-http1) — HTTP/1 client/server implementation using this
data/releases.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Releases
2
2
 
3
+ ## v0.69.0
4
+
5
+ - Add `Protocol::HTTP::Body::Readable#to_io` for obtaining an IO-compatible stream adapter.
6
+ - Avoid creating an implicit buffered output for `Protocol::HTTP::Body::Stream`.
7
+
3
8
  ## v0.68.0
4
9
 
5
10
  - Add HTTP status descriptions.
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.68.0
4
+ version: 0.69.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file