summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorShishir Joshi <shishir127@users.noreply.github.com>2022-06-16 16:46:47 +0530
committerGitHub <noreply@github.com>2022-06-16 20:16:47 +0900
commit63546bfc1581d4abec2a0d846106a1c0afc0efa9 (patch)
tree11082baf1359d2775f68710b5a7b2c3aa2f7b24a /test/net
parent8ef312fc5bfa9c585a917dc006eeb7f2cad1b73f (diff)
downloadruby-63546bfc1581d4abec2a0d846106a1c0afc0efa9.tar.gz
HTTPHeader.content_range throws error on non-byte units
* Added a nil check in Net::HTTPHeader#initialize_http_header for keys in the header that do not have any value * Returning nil from the content_range method instead of raising an error when the unit in the content-range header is not bytes * Modified initialize_http_header to match trunk fix [Bug #11450] fix https://github.com/ruby/ruby/pull/1018
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_httpheader.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb
index cfbe36bcfd..20ffd91beb 100644
--- a/test/net/http/test_httpheader.rb
+++ b/test/net/http/test_httpheader.rb
@@ -308,6 +308,14 @@ 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
@@ -317,6 +325,8 @@ 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?