ruby-changes:72189
From: Nobuyoshi <ko1@a...>
Date: Thu, 16 Jun 2022 22:12:44 +0900 (JST)
Subject: [ruby-changes:72189] 2223eb082a (master): Revert "HTTPHeader.content_range throws error on non-byte units"
https://git.ruby-lang.org/ruby.git/commit/?id=2223eb082a From 2223eb082afa6d05321b69df783d4133b9aacba6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 16 Jun 2022 22:10:59 +0900 Subject: 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 https://github.com/ruby/ruby/blob/trunk/lib/net/http/header.rb#L338 # 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 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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpheader.rb#L308 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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpheader.rb#L317 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? -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/