diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-28 08:05:57 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-28 08:05:57 +0000 |
commit | 6360243fd2e385fbdc14eb5c62ae622ac2ea7021 (patch) | |
tree | 92ba2a4445675ee3de97c0f0556c178ee78db124 /lib/webrick/httpservlet/filehandler.rb | |
parent | 2bdcd0bddea7de08b8845918ed27185fa3125734 (diff) | |
download | ruby-6360243fd2e385fbdc14eb5c62ae622ac2ea7021.tar.gz |
webrick: use IO.copy_stream for single range response
This is also compatible with range responses generated
by Rack::File (tested with rack 2.0.3).
* lib/webrick/httpresponse.rb (send_body_io): use Content-Range
* lib/webrick/httpservlet/filehandler.rb (make_partial_content):
use File object for the single range case
* test/webrick/test_filehandler.rb (get_res_body): use send_body
to test result
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpservlet/filehandler.rb')
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index 2c02d0ffe7..c910044742 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -116,17 +116,10 @@ module WEBrick elsif range = ranges[0] first, last = prepare_range(range, filesize) raise HTTPStatus::RequestRangeNotSatisfiable if first < 0 - if last == filesize - 1 - content = io.dup - content.pos = first - else - io.pos = first - content = io.read(last-first+1) - end res['content-type'] = mtype res['content-range'] = "bytes #{first}-#{last}/#{filesize}" res['content-length'] = last - first + 1 - res.body = content + res.body = io.dup else raise HTTPStatus::BadRequest end |