Skip to content

Commit 8aad930

Browse files
committed
Restore coverage validation
1 parent fbacccf commit 8aad930

6 files changed

Lines changed: 50 additions & 5 deletions

File tree

‎lib/protocol/http/body/deflate.rb‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,15 @@ def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL)
110110
#
111111
# @returns [String | Nil] the compressed chunk or `nil` if the stream is closed.
112112
def read
113-
return if @stream.finished?
113+
if @stream.finished?
114+
return
115+
end
114116

115117
# The stream might have been closed while waiting for the chunk to come in.
116-
while chunk = super
118+
loop do
119+
chunk = super
120+
break unless chunk
121+
117122
unless chunk.empty?
118123
@input_length += chunk.bytesize
119124

‎lib/protocol/http/body/stream.rb‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def read(length = nil, buffer = nil)
8686
return buffer
8787
end
8888
else
89-
while chunk = read_next
89+
loop do
90+
chunk = read_next
91+
break unless chunk
92+
9093
buffer << chunk
9194
end
9295

@@ -202,7 +205,11 @@ def read_until(pattern, offset = 0, chomp: false)
202205
@buffer ||= read_next
203206
return nil if @buffer.nil?
204207

205-
until index = @buffer.index(pattern, offset)
208+
index = nil
209+
loop do
210+
index = @buffer.index(pattern, offset)
211+
break if index
212+
206213
offset = @buffer.bytesize - split_offset
207214

208215
offset = 0 if offset < 0

‎lib/protocol/http/header/accept_charset.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@ class AcceptCharset < Split
1717
# https://tools.ietf.org/html/rfc7231#section-5.3.3
1818
CHARSET = /\A(?<name>#{TOKEN})(;q=(?<q>#{QVALUE}))?\z/
1919

20+
# A parsed character set entry with an optional quality factor.
2021
Charset = Struct.new(:name, :q) do
22+
# The quality factor for this character set.
23+
#
24+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
2125
def quality_factor
2226
(q || 1.0).to_f
2327
end
2428

29+
# Compare character sets by descending quality factor.
30+
#
31+
# @parameter other [Charset] the other character set to compare.
32+
# @returns [Integer] the comparison result.
2533
def <=> other
2634
other.quality_factor <=> self.quality_factor
2735
end

‎lib/protocol/http/header/accept_encoding.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ class AcceptEncoding < Split
2020
# https://tools.ietf.org/html/rfc7231#section-5.3.4
2121
ENCODING = /\A(?<name>#{TOKEN})(;q=(?<q>#{QVALUE}))?\z/
2222

23+
# A parsed content encoding entry with an optional quality factor.
2324
Encoding = Struct.new(:name, :q) do
25+
# The quality factor for this encoding.
26+
#
27+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
2428
def quality_factor
2529
(q || 1.0).to_f
2630
end
2731

32+
# Compare encodings by descending quality factor.
33+
#
34+
# @parameter other [Encoding] the other encoding to compare.
35+
# @returns [Integer] the comparison result.
2836
def <=> other
2937
other.quality_factor <=> self.quality_factor
3038
end

‎lib/protocol/http/header/accept_language.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ class AcceptLanguage < Split
2323
# https://greenbytes.de/tech/webdav/rfc7231.html#quality.values
2424
LANGUAGE = /\A(?<name>#{NAME})(\s*;\s*q=(?<q>#{QVALUE}))?\z/
2525

26+
# A parsed language entry with an optional quality factor.
2627
Language = Struct.new(:name, :q) do
28+
# The quality factor for this language.
29+
#
30+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
2731
def quality_factor
2832
(q || 1.0).to_f
2933
end
3034

35+
# Compare languages by descending quality factor.
36+
#
37+
# @parameter other [Language] the other language to compare.
38+
# @returns [Integer] the comparison result.
3139
def <=> other
3240
other.quality_factor <=> self.quality_factor
3341
end

‎lib/protocol/http/header/te.rb‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@ class TE < Split
4545

4646
# A single transfer coding entry with optional quality factor
4747
TransferCoding = Struct.new(:name, :q) do
48+
# The quality factor for this transfer coding.
49+
#
50+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
4851
def quality_factor
4952
(q || 1.0).to_f
5053
end
5154

55+
# Compare transfer codings by descending quality factor.
56+
#
57+
# @parameter other [TransferCoding] the other transfer coding to compare.
58+
# @returns [Integer] the comparison result.
5259
def <=> other
5360
other.quality_factor <=> self.quality_factor
5461
end
5562

63+
# Convert the transfer coding entry to a header value.
64+
#
65+
# @returns [String] the formatted transfer coding with quality factor when present.
5666
def to_s
5767
if q && q != 1.0
5868
"#{name};q=#{q}"
@@ -143,4 +153,3 @@ def self.trailer?
143153
end
144154
end
145155
end
146-

0 commit comments

Comments
 (0)