Revert "HTTPHeader.content_range throws error on non-byte units"

This reverts commit 63546bfc15.
This commit is contained in:
Nobuyoshi Nakada 2022-06-16 22:10:59 +09:00
Родитель 1cc64a5514
Коммит 2223eb082a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
2 изменённых файлов: 2 добавлений и 12 удалений

Просмотреть файл

@ -338,8 +338,8 @@ module Net::HTTPHeader
# fits inside the full entity body, as range of byte offsets.
def content_range
return nil unless @header['content-range']
m = %r<bytes\s+(\d+)-(\d+)/(\d+|\*)>i.match(self['Content-Range'])
return nil if m.nil?
m = %r<bytes\s+(\d+)-(\d+)/(\d+|\*)>i.match(self['Content-Range']) or
raise Net::HTTPHeaderSyntaxError, 'wrong Content-Range format'
m[1].to_i .. m[2].to_i
end

Просмотреть файл

@ -308,14 +308,6 @@ class HTTPHeaderTest < Test::Unit::TestCase
end
def test_content_range
@c['Content-Range'] = "bytes 0-499/1000"
assert_equal 0..499, @c.content_range
@c['Content-Range'] = "bytes 1-500/1000"
assert_equal 1..500, @c.content_range
@c['Content-Range'] = "bytes 1-1/1000"
assert_equal 1..1, @c.content_range
@c['Content-Range'] = "tokens 1-1/1000"
assert_equal nil, @c.content_range
end
def test_range_length
@ -325,8 +317,6 @@ class HTTPHeaderTest < Test::Unit::TestCase
assert_equal 500, @c.range_length
@c['Content-Range'] = "bytes 1-1/1000"
assert_equal 1, @c.range_length
@c['Content-Range'] = "tokens 1-1/1000"
assert_equal nil, @c.range_length
end
def test_chunked?