From 0478a37903d7f8c09ff841911efd0f5f57b7ca21 Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 28 Mar 2018 08:06:02 +0000 Subject: [PATCH] test/webrick/test_filehandler.rb: stricter multipart range test We need to ensure we generate compatibile output in the face of future changes * test/webrick/test_filehandler.rb (test_make_partial_content): check response body git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/webrick/test_filehandler.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index ac97c15561..99bc1420b8 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -75,6 +75,23 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase res = make_range_response(filename, "bytes=0-0, -2") assert_match(%r{^multipart/byteranges}, res["content-type"]) + body = get_res_body(res) + boundary = /; boundary=(.+)/.match(res['content-type'])[1] + off = filesize - 2 + last = filesize - 1 + + exp = "--#{boundary}\r\n" \ + "Content-Type: text/plain\r\n" \ + "Content-Range: bytes 0-0/#{filesize}\r\n" \ + "\r\n" \ + "#{IO.read(__FILE__, 1)}\r\n" \ + "--#{boundary}\r\n" \ + "Content-Type: text/plain\r\n" \ + "Content-Range: bytes #{off}-#{last}/#{filesize}\r\n" \ + "\r\n" \ + "#{IO.read(__FILE__, 2, off)}\r\n" \ + "--#{boundary}--\r\n" + assert_equal exp, body end def test_filehandler