protocol-http 0.39.0 → 0.40.0

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: bcd8228b665455c02862f4019d3a44028c015339a43bcf6d3c7f338a3f9b2173
4
- data.tar.gz: d7f99542317ee6624aa98538318ec78eb8938d0a34d16fd55ae505ec08247745
3
+ metadata.gz: 10e80047df314ab51026467f51437b52b9c09efda85f028ae1835f5e8ff4ae6c
4
+ data.tar.gz: '08c4a65646072f0e229cbd096a10d7c3f701d5c72edb17c5f9ee2cc112d574bb'
5
5
  SHA512:
6
- metadata.gz: b3d68dc17a9b7da1cd54d9adab3bcbc4008f61c9e50e124264b9aec73c14c7af61d07528302d57b2ad0aef2c0f1e33ed9057ee7755b266d919578c96b1508105
7
- data.tar.gz: 48c95c2b547e066dbe467dd7a282628f9890c1c61bb58ada51bcecbe86bf278c91f1ee53ab89e873a9ae3609b1e5b594dc58c97128d1641bff782bf8f15a6f6d
6
+ metadata.gz: 2a7c1dcdeffbf00442217783b7b01a93ae866b1471a1441729931cc485d5eef491c03fb22b2a5ee05dfcf87c4818be41706cb10abe78f37de6dd4187f9d75fb6
7
+ data.tar.gz: 778915a18c596ff9ebb21f2d0b5bc6da4f59de7248d1ac08ee3dddaa9526a8b17de6fb93b002fe048ed4b842370d161499eaaf1d70aeb7dd4fe41281dc8ed90e
checksums.yaml.gz.sig CHANGED
@@ -1 +1,5 @@
1
- :�R��R�u��O�S�����P��n�v�td������s��8]�ը,�B�)��y-u��}��g���F7��Nbf�ӊD<y����r�:6�js��[���4�~��p6ab-u%�Ű��G�O%C���e�����RUK\\d���Ġ��[���E|GN?�v��I�-7���lM�OF%m�ך�/,���i��_ل�ZK>3�q+-�0b�﹈��95�����ݗ3�T87`oT᳌��G���r���rT|=j��u2l��n���N���`
1
+ &ȹ�ё���R�@�^���1gp^>w��j���={$�M@�y0�v� �h��͚%��HF��;��t����>��J����
2
+ ��bׂOc�*�;;��hԻ]�f�@0�N�D�62����bIYRT�������}�pD�w�m�}�����7o'�i�""+qQ"4#}�i,�m�o&�LG`7�n]�F���������a�[ņbBs1�k�Bloϛ���/Nq8oA��=ɮ�9U��=
3
+ �d(�S_2������q�(�nZ�^�A�ٶ�K/1溯.j(��Q=�l��=O�*uQNK��J�bk���j�_ϒt
4
+ �|E����������T[1��T�oǨuĊWӪ������g���Y�49�
5
+ �q�}��/��q� �P
@@ -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, **options)
196
- read_until(separator, **options)
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
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.39.0"
8
+ VERSION = "0.40.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
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.39.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-14 00:00:00.000000000 Z
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