protocol-http 0.22.7 → 0.22.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/body/stream.rb +57 -20
- data/lib/protocol/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +36 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1672fc86e8bbe321f648e200205314ee472f9b01c326882f089e149b584f11
|
4
|
+
data.tar.gz: acbe42e8d8af4b50d018325b0204cec345ed161fbb7eba0583a512ce65c0a713
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cda8cf0c22f5d9a01a308cc83f2b80209bc3ad98ec84c5082d0846e6835224bb6c2ef9f9cc25b12eaa542f77000fa13c7cc9d2aba2107ba362e737c13ef90a0
|
7
|
+
data.tar.gz: 4fcd1417896726bce8019ea8fc5ebdbd92f07484611855c4cc04b0ba1a59deb18a79dd1d0c4b8978b7ec48c3c27376b09f3d75cd33728d4d5474093a08699694
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
#
|
3
3
|
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -20,15 +20,19 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
+
require_relative 'buffered'
|
24
|
+
|
23
25
|
module Protocol
|
24
26
|
module HTTP
|
25
27
|
module Body
|
26
28
|
# The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
|
27
29
|
class Stream
|
28
|
-
def initialize(input, output)
|
30
|
+
def initialize(input, output = Buffered.new)
|
29
31
|
@input = input
|
30
32
|
@output = output
|
31
33
|
|
34
|
+
raise ArgumentError, "Non-writable output!" unless output.respond_to?(:write)
|
35
|
+
|
32
36
|
# Will hold remaining data in `#read`.
|
33
37
|
@buffer = nil
|
34
38
|
@closed = false
|
@@ -45,29 +49,62 @@ module Protocol
|
|
45
49
|
# @param buffer [String] the buffer which will receive the data
|
46
50
|
# @return a buffer containing the data
|
47
51
|
def read(length = nil, buffer = nil)
|
52
|
+
return '' if length == 0
|
53
|
+
|
48
54
|
buffer ||= Async::IO::Buffer.new
|
49
|
-
|
55
|
+
|
56
|
+
# Take any previously buffered data and replace it into the given buffer.
|
57
|
+
if @buffer
|
58
|
+
buffer.replace(@buffer)
|
59
|
+
@buffer = nil
|
60
|
+
end
|
50
61
|
|
51
|
-
|
52
|
-
|
53
|
-
|
62
|
+
if length
|
63
|
+
while buffer.bytesize < length and chunk = read_next
|
64
|
+
buffer << chunk
|
65
|
+
end
|
66
|
+
|
67
|
+
# This ensures the subsequent `slice!` works correctly.
|
68
|
+
buffer.force_encoding(Encoding::BINARY)
|
69
|
+
|
70
|
+
# This will be at least one copy:
|
71
|
+
@buffer = buffer.byteslice(length, buffer.bytesize)
|
54
72
|
|
55
|
-
|
73
|
+
# This should be zero-copy:
|
74
|
+
buffer.slice!(length)
|
56
75
|
|
57
|
-
if
|
58
|
-
|
59
|
-
# But byteslice will generate a hidden copy. So let's freeze it first:
|
60
|
-
@buffer.freeze
|
61
|
-
|
62
|
-
buffer << @buffer.byteslice(0, remaining_length)
|
63
|
-
@buffer = @buffer.byteslice(remaining_length, @buffer.bytesize)
|
76
|
+
if buffer.empty?
|
77
|
+
return nil
|
64
78
|
else
|
65
|
-
|
66
|
-
@buffer = nil
|
79
|
+
return buffer
|
67
80
|
end
|
81
|
+
else
|
82
|
+
while chunk = read_next
|
83
|
+
buffer << chunk
|
84
|
+
end
|
85
|
+
|
86
|
+
return buffer
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Read at most `length` bytes from the stream. Will avoid reading from the underlying stream if possible.
|
91
|
+
def read_partial(length = nil)
|
92
|
+
if @buffer
|
93
|
+
buffer = @buffer
|
94
|
+
@buffer = nil
|
95
|
+
else
|
96
|
+
buffer = read_next
|
68
97
|
end
|
69
98
|
|
70
|
-
|
99
|
+
if buffer and length
|
100
|
+
if buffer.bytesize > length
|
101
|
+
# This ensures the subsequent `slice!` works correctly.
|
102
|
+
buffer.force_encoding(Encoding::BINARY)
|
103
|
+
|
104
|
+
@buffer = buffer.byteslice(length, buffer.bytesize)
|
105
|
+
buffer.slice!(length)
|
106
|
+
end
|
107
|
+
end
|
71
108
|
|
72
109
|
return buffer
|
73
110
|
end
|
@@ -80,7 +117,7 @@ module Protocol
|
|
80
117
|
buffer&.clear
|
81
118
|
return
|
82
119
|
end
|
83
|
-
|
120
|
+
|
84
121
|
if @buffer.bytesize > length
|
85
122
|
chunk = @buffer.byteslice(0, length)
|
86
123
|
@buffer = @buffer.byteslice(length, @buffer.bytesize)
|
@@ -124,10 +161,10 @@ module Protocol
|
|
124
161
|
end
|
125
162
|
|
126
163
|
# Close the input and output bodies.
|
127
|
-
def close
|
164
|
+
def close(error = nil)
|
128
165
|
self.close_read
|
129
166
|
self.close_write
|
130
|
-
|
167
|
+
|
131
168
|
return nil
|
132
169
|
ensure
|
133
170
|
@closed = true
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,47 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Bruno Sutic
|
9
|
+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
|
- !ruby/object:Gem::Dependency
|
14
47
|
name: bundler
|
metadata.gz.sig
ADDED
Binary file
|