protocol-http 0.22.6 → 0.22.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2d1f5f6a59c2a1971e7d5e6ff1fdcfe73b67ad5046e5404e5daa30e40e39d83
4
- data.tar.gz: aad5c5263c1086a6164412549f5d549a101b8871453770bcb4e7dc4f34f24044
3
+ metadata.gz: 3941486c86fe210a4ba79c2c77c73bfa3de8cd7cfbfe892c4b6d0b48699260c2
4
+ data.tar.gz: afd65fb56ed88d184249ab56d87271f6926d398e8460135315e571b1848416a5
5
5
  SHA512:
6
- metadata.gz: f0ed818d3d25dfba4cbbe6f44d5255b711aa657d3c3b85889d88e807a6fc551488c075bb0257f3c3f87e8855fa4389132bf1a931e0b7b8d3e38382fe48bcd732
7
- data.tar.gz: 8a715d2bcd6b33c07f03b05bef621a87b75796c32d0a7aec9076125db3cdfb0c580513c6b7b4844fd0696fcaf0eb8f1df0f4542e23e4ea781cbcf140999530fb
6
+ metadata.gz: 10e885a3c13ec3a380c774b62e4e5fdd1a0a378766eca8650733909917ab964ccb85b39aa39105d522d8efd93b917a546029c1d70260fef4ba719c984f055926
7
+ data.tar.gz: b67aa62dc2d4f5e5c3e6d97cd4f40044de8a7b02dac0343aa796dcdf936171f3ec097819d3e70ec4af76ec493496c3507b6ec62302571b76b5ac359e9d015641
@@ -72,7 +72,7 @@ module Protocol
72
72
  stream.write(chunk)
73
73
  end
74
74
  ensure
75
- stream.close($!)
75
+ stream.close
76
76
  end
77
77
 
78
78
  # Read all remaining chunks into a buffered body and close the underlying input.
@@ -76,6 +76,11 @@ module Protocol
76
76
  @buffer ||= read_next
77
77
  chunk = nil
78
78
 
79
+ unless @buffer
80
+ buffer&.clear
81
+ return
82
+ end
83
+
79
84
  if @buffer.bytesize > length
80
85
  chunk = @buffer.byteslice(0, length)
81
86
  @buffer = @buffer.byteslice(length, @buffer.bytesize)
@@ -94,7 +99,12 @@ module Protocol
94
99
  end
95
100
 
96
101
  def write(buffer)
97
- @output.write(buffer)
102
+ if @output
103
+ @output.write(buffer)
104
+ return buffer.bytesize
105
+ else
106
+ raise IOError, "Stream is not writable, output has been closed!"
107
+ end
98
108
  end
99
109
 
100
110
  alias write_nonblock write
@@ -104,17 +114,21 @@ module Protocol
104
114
 
105
115
  def close_read
106
116
  @input&.close
117
+ @input = nil
107
118
  end
108
119
 
109
120
  # close must never be called on the input stream. huh?
110
121
  def close_write
111
122
  @output&.close
123
+ @output = nil
112
124
  end
113
125
 
114
126
  # Close the input and output bodies.
115
127
  def close
116
128
  self.close_read
117
129
  self.close_write
130
+
131
+ return nil
118
132
  ensure
119
133
  @closed = true
120
134
  end
@@ -132,11 +146,11 @@ module Protocol
132
146
  private
133
147
 
134
148
  def read_next
135
- if chunk = @input&.read
136
- return chunk
149
+ if @input
150
+ return @input.read
137
151
  else
138
152
  @input = nil
139
- return nil
153
+ raise IOError, "Stream is not readable, input has been closed!"
140
154
  end
141
155
  end
142
156
  end
@@ -101,20 +101,27 @@ module Protocol
101
101
  # An array of `[key, value]` pairs.
102
102
  attr :fields
103
103
 
104
- # @return the trailer if there are any.
104
+ # @returns Whether there are any trailers.
105
105
  def trailer?
106
106
  @tail != nil
107
107
  end
108
108
 
109
- # Record the current headers, and prepare to receive trailer.
109
+ # Record the current headers, and prepare to add trailers.
110
+ #
111
+ # This method is typically used after headers are sent to capture any
112
+ # additional headers which should then be sent as trailers.
113
+ #
114
+ # A sender that intends to generate one or more trailer fields in a
115
+ # message should generate a trailer header field in the header section of
116
+ # that message to indicate which fields might be present in the trailers.
117
+ #
118
+ # @parameter names [Array] The trailer header names which will be added later.
119
+ # @yields block {|name, value| ...} The trailer headers if any.
120
+ # @returns An enumerator which is suitable for iterating over trailers.
110
121
  def trailer!(&block)
111
122
  @tail ||= @fields.size
112
123
 
113
- return to_enum(:trailer) unless block_given?
114
-
115
- if @tail
116
- @fields.drop(@tail).each(&block)
117
- end
124
+ return trailer(&block)
118
125
  end
119
126
 
120
127
  # Enumerate all headers in the trailer, if there are any.
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Protocol
24
24
  module HTTP
25
- VERSION = "0.22.6"
25
+ VERSION = "0.22.7"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.6
4
+ version: 0.22.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-28 00:00:00.000000000 Z
11
+ date: 2022-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.1.6
115
+ rubygems_version: 3.3.7
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Provides abstractions to handle HTTP protocols.