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 +4 -4
- data/lib/protocol/http/body/readable.rb +1 -1
- data/lib/protocol/http/body/stream.rb +18 -4
- data/lib/protocol/http/headers.rb +14 -7
- data/lib/protocol/http/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3941486c86fe210a4ba79c2c77c73bfa3de8cd7cfbfe892c4b6d0b48699260c2
|
4
|
+
data.tar.gz: afd65fb56ed88d184249ab56d87271f6926d398e8460135315e571b1848416a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10e885a3c13ec3a380c774b62e4e5fdd1a0a378766eca8650733909917ab964ccb85b39aa39105d522d8efd93b917a546029c1d70260fef4ba719c984f055926
|
7
|
+
data.tar.gz: b67aa62dc2d4f5e5c3e6d97cd4f40044de8a7b02dac0343aa796dcdf936171f3ec097819d3e70ec4af76ec493496c3507b6ec62302571b76b5ac359e9d015641
|
@@ -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
|
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
|
136
|
-
return
|
149
|
+
if @input
|
150
|
+
return @input.read
|
137
151
|
else
|
138
152
|
@input = nil
|
139
|
-
|
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
|
-
# @
|
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
|
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
|
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.
|
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.
|
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-
|
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.
|
115
|
+
rubygems_version: 3.3.7
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Provides abstractions to handle HTTP protocols.
|