From 2223eb082afa6d05321b69df783d4133b9aacba6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Jun 2022 22:10:59 +0900 Subject: [PATCH] Revert "HTTPHeader.content_range throws error on non-byte units" This reverts commit 63546bfc1581d4abec2a0d846106a1c0afc0efa9. --- lib/net/http/header.rb | 4 ++-- test/net/http/test_httpheader.rb | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index e96d62732a..a8901e79cb 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -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 = %ri.match(self['Content-Range']) - return nil if m.nil? + m = %ri.match(self['Content-Range']) or + raise Net::HTTPHeaderSyntaxError, 'wrong Content-Range format' m[1].to_i .. m[2].to_i end diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb index 20ffd91beb..cfbe36bcfd 100644 --- a/test/net/http/test_httpheader.rb +++ b/test/net/http/test_httpheader.rb @@ -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?