protocol-http 0.38.0 → 0.40.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/body/file.rb +10 -0
- data/lib/protocol/http/body/stream.rb +56 -2
- data/lib/protocol/http/version.rb +1 -1
- data.tar.gz.sig +1 -2
- metadata +2 -2
- 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: 10e80047df314ab51026467f51437b52b9c09efda85f028ae1835f5e8ff4ae6c
|
4
|
+
data.tar.gz: '08c4a65646072f0e229cbd096a10d7c3f701d5c72edb17c5f9ee2cc112d574bb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7c1dcdeffbf00442217783b7b01a93ae866b1471a1441729931cc485d5eef491c03fb22b2a5ee05dfcf87c4818be41706cb10abe78f37de6dd4187f9d75fb6
|
7
|
+
data.tar.gz: 778915a18c596ff9ebb21f2d0b5bc6da4f59de7248d1ac08ee3dddaa9526a8b17de6fb93b002fe048ed4b842370d161499eaaf1d70aeb7dd4fe41281dc8ed90e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -18,6 +18,7 @@ module Protocol
|
|
18
18
|
|
19
19
|
def initialize(file, range = nil, size: file.size, block_size: BLOCK_SIZE)
|
20
20
|
@file = file
|
21
|
+
@range = range
|
21
22
|
|
22
23
|
@block_size = block_size
|
23
24
|
|
@@ -26,6 +27,7 @@ module Protocol
|
|
26
27
|
@offset = range.min
|
27
28
|
@length = @remaining = range.size
|
28
29
|
else
|
30
|
+
@file.seek(0)
|
29
31
|
@offset = 0
|
30
32
|
@length = @remaining = size
|
31
33
|
end
|
@@ -51,11 +53,19 @@ module Protocol
|
|
51
53
|
true
|
52
54
|
end
|
53
55
|
|
56
|
+
def buffered
|
57
|
+
self.class.new(@file.dup, @range, block_size: @block_size)
|
58
|
+
end
|
59
|
+
|
54
60
|
def rewind
|
55
61
|
@file.seek(@offset)
|
56
62
|
@remaining = @length
|
57
63
|
end
|
58
64
|
|
65
|
+
def rewindable?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
59
69
|
def read
|
60
70
|
if @remaining > 0
|
61
71
|
amount = [@remaining, @block_size].min
|
@@ -191,9 +191,63 @@ module Protocol
|
|
191
191
|
# Read a single line from the stream.
|
192
192
|
#
|
193
193
|
# @parameter separator [String] The line separator, defaults to `\n`.
|
194
|
+
# @parameter limit [Integer] The maximum number of bytes to read.
|
194
195
|
# @parameter *options [Hash] Additional options, passed to {read_until}.
|
195
|
-
def gets(separator = NEWLINE,
|
196
|
-
|
196
|
+
def gets(separator = NEWLINE, limit = nil, chomp: false)
|
197
|
+
# If the separator is an integer, it is actually the limit:
|
198
|
+
if separator.is_a?(Integer)
|
199
|
+
limit = separator
|
200
|
+
separator = NEWLINE
|
201
|
+
end
|
202
|
+
|
203
|
+
# If no separator is given, this is the same as a read operation:
|
204
|
+
if separator.nil?
|
205
|
+
return read(limit)
|
206
|
+
end
|
207
|
+
|
208
|
+
# We don't want to split on the separator, so we subtract the size of the separator:
|
209
|
+
split_offset = separator.bytesize - 1
|
210
|
+
|
211
|
+
@buffer ||= read_next
|
212
|
+
return nil if @buffer.nil?
|
213
|
+
|
214
|
+
offset = 0
|
215
|
+
until index = @buffer.index(separator, offset)
|
216
|
+
offset = @buffer.bytesize - split_offset
|
217
|
+
offset = 0 if offset < 0
|
218
|
+
|
219
|
+
# If we have gone past the limit, we are done:
|
220
|
+
if limit and offset >= limit
|
221
|
+
@buffer.freeze
|
222
|
+
matched = @buffer.byteslice(0, limit)
|
223
|
+
@buffer = @buffer.byteslice(limit, @buffer.bytesize)
|
224
|
+
return matched
|
225
|
+
end
|
226
|
+
|
227
|
+
# Read more data:
|
228
|
+
if chunk = read_next
|
229
|
+
@buffer << chunk
|
230
|
+
else
|
231
|
+
# No more data could be read, return the remaining data:
|
232
|
+
buffer = @buffer
|
233
|
+
@buffer = nil
|
234
|
+
|
235
|
+
return @buffer
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Freeze the buffer, as this enables us to use byteslice without generating a hidden copy:
|
240
|
+
@buffer.freeze
|
241
|
+
|
242
|
+
if limit and index > limit
|
243
|
+
line = @buffer.byteslice(0, limit)
|
244
|
+
@buffer = @buffer.byteslice(limit, @buffer.bytesize)
|
245
|
+
else
|
246
|
+
line = @buffer.byteslice(0, index+(chomp ? 0 : separator.bytesize))
|
247
|
+
@buffer = @buffer.byteslice(index+separator.bytesize, @buffer.bytesize)
|
248
|
+
end
|
249
|
+
|
250
|
+
return line
|
197
251
|
end
|
198
252
|
end
|
199
253
|
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�O&c#�r�"�5��0�gx���t�k{�>�\::v�ju����s�ŷ�2]�W��[iq��,�p��רڟ&�s=4n�=�ۅq�ɍ)�(�F�u�GvT8�5�C�pXL~�:� ��e���Y�+�,�����/�Iߐ��x�,@E�Љ�|����:�V��`��Q
|
1
|
+
I�1�a�����g}�nm�"�KL�+VJC%���t��k�e}�s}�*�xٻ3c7�9��d�-:���i�,Z����+0%��<�R�"E�|�w5��AM���'z��b�c��sG]B�]�b���ڍ�I+
|
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.
|
4
|
+
version: 0.40.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -47,7 +47,7 @@ cert_chain:
|
|
47
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
48
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
49
49
|
-----END CERTIFICATE-----
|
50
|
-
date: 2024-10-
|
50
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
51
51
|
dependencies: []
|
52
52
|
description:
|
53
53
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|