protocol-rack 0.14.0 → 0.15.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: 9d3039968903e553afd725e0d5452f7d4b3975c9596b20ebbe2eeba354e83dba
4
- data.tar.gz: 2b692f3676d057dc9c5b380bf13a5c1f79fc23df08f952b2a7b8d79786cb0713
3
+ metadata.gz: a0994443c638a7cf147afcb7a8b88a1a6e5e8ab607071c10792d65c912fb9b37
4
+ data.tar.gz: 22a6c27089e34db868a7af15fac1061979791872c811aef51762b68435fb9346
5
5
  SHA512:
6
- metadata.gz: b839c48ff5275a8599c4cc98feb27501e4c84815d0945a9a78f239391cae24cbfb2eaf25142986deaccc6b95a184e6e4a9638d6634d210e02021388ddba3d172
7
- data.tar.gz: f26a5aed151fcb2a253a36b9ffed7116665f8c16aac2d17523c6da3f5afc868331e038f2fd4c187e50fd21452cf2daacecbae376d4d80ce3832659f05b353fb6
6
+ metadata.gz: 60caa82495eb534bfb3367009b7567304c1c36b2db646fbee99d7c68eaba810c9913ad8c847c7939e0d60bb29bd049bdfb67ff365f68f9142b65d6cf7a7bf8f8
7
+ data.tar.gz: 63313385d9603b0bdaddeb39410dbcf7a3485652478d886ffbb5e8ea926a1b5006bcbd21bdc3b6a3851e43f1f601ded523021d700cd00dd0d2ab252b529378fa
checksums.yaml.gz.sig CHANGED
Binary file
@@ -119,7 +119,7 @@ module Protocol
119
119
 
120
120
  # HTTP/2 prefers `:authority` over `host`, so we do this for backwards compatibility.
121
121
  env[CGI::HTTP_HOST] ||= request.authority
122
-
122
+
123
123
  if peer = request.peer
124
124
  env[CGI::REMOTE_ADDR] = peer.ip_address
125
125
  end
@@ -4,7 +4,7 @@
4
4
  # Copyright, 2022-2025, by Samuel Williams.
5
5
  # Copyright, 2023, by Genki Takiuchi.
6
6
 
7
- require "protocol/http/body/stream"
7
+ require "io/stream/readable"
8
8
 
9
9
  module Protocol
10
10
  module Rack
@@ -14,22 +14,21 @@ module Protocol
14
14
  #
15
15
  # This implementation is not always rewindable, to avoid buffering the input when handling large uploads. See {Rewindable} for more details.
16
16
  class Input
17
+ include IO::Stream::Readable
18
+
17
19
  # Initialize the input wrapper.
18
20
  # @parameter body [Protocol::HTTP::Body::Readable]
19
- def initialize(body)
21
+ def initialize(body, ...)
20
22
  @body = body
21
23
  @closed = false
22
24
 
23
- # Will hold remaining data in `#read`.
24
- @buffer = nil
25
+ super(...)
25
26
  end
26
27
 
27
28
  # The input body.
28
29
  # @attribute [Protocol::HTTP::Body::Readable]
29
30
  attr :body
30
31
 
31
- include Protocol::HTTP::Body::Stream::Reader
32
-
33
32
  # Enumerate chunks of the request body.
34
33
  # @yields {|chunk| ...}
35
34
  # @parameter chunk [String]
@@ -65,7 +64,6 @@ module Protocol
65
64
  # If the body is not rewindable, this will fail.
66
65
  @body.rewind
67
66
 
68
- @buffer = nil
69
67
  @finished = false
70
68
  @closed = false
71
69
 
@@ -87,7 +85,11 @@ module Protocol
87
85
 
88
86
  private
89
87
 
90
- def read_next
88
+ def flush
89
+ # No-op.
90
+ end
91
+
92
+ def sysread(size, buffer = nil)
91
93
  if @body
92
94
  # User's may forget to call #close...
93
95
  if chunk = @body.read
@@ -98,7 +100,15 @@ module Protocol
98
100
  @closed = true
99
101
  end
100
102
 
101
- return chunk
103
+ if buffer
104
+ # If a buffer is provided, we copy the chunk into it:
105
+ buffer.replace(chunk)
106
+ else
107
+ # Otherwise we return the chunk directly:
108
+ buffer = chunk
109
+ end
110
+
111
+ return buffer
102
112
  else
103
113
  unless @closed
104
114
  # So if we are at the end of the stream, we close it automatically:
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2022-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "body"
7
7
  require_relative "constants"
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.14.0"
8
+ VERSION = "0.15.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -67,6 +67,10 @@ run proc{|env|
67
67
 
68
68
  Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
69
69
 
70
+ ### v0.15.0
71
+
72
+ - Use `IO::Stream::Readable` for the input body, which is a better tested and more robust interface.
73
+
70
74
  ### v0.14.0
71
75
 
72
76
  - Handling of `HEAD` requests is now more robust.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.15.0
4
+
5
+ - Use `IO::Stream::Readable` for the input body, which is a better tested and more robust interface.
6
+
3
7
  ## v0.14.0
4
8
 
5
9
  - Handling of `HEAD` requests is now more robust.
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.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -40,6 +40,20 @@ cert_chain:
40
40
  -----END CERTIFICATE-----
41
41
  date: 1980-01-02 00:00:00.000000000 Z
42
42
  dependencies:
43
+ - !ruby/object:Gem::Dependency
44
+ name: io-stream
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0.10'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0.10'
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: protocol-http
45
59
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file