summaryrefslogtreecommitdiff
path: root/lib/webrick
diff options
context:
space:
mode:
Diffstat (limited to 'lib/webrick')
-rw-r--r--lib/webrick/httpservlet/erbhandler.rb3
-rw-r--r--lib/webrick/httpservlet/filehandler.rb8
-rw-r--r--lib/webrick/httputils.rb2
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/webrick/httpservlet/erbhandler.rb b/lib/webrick/httpservlet/erbhandler.rb
index 40b7a57610..b9d5e65b65 100644
--- a/lib/webrick/httpservlet/erbhandler.rb
+++ b/lib/webrick/httpservlet/erbhandler.rb
@@ -29,7 +29,8 @@ module WEBrick
begin
data = open(@script_filename){|io| io.read }
res.body = evaluate(ERB.new(data), req, res)
- res['content-type'] = "text/html"
+ res['content-type'] =
+ HTTPUtils::mime_type(@script_filename, @config[:MimeTypes])
rescue StandardError => ex
raise
rescue Exception => ex
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 9e1a439b14..8525d7bb1b 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -72,13 +72,15 @@ module WEBrick
def make_partial_content(req, res, filename, filesize)
mtype = HTTPUtils::mime_type(filename, @config[:MimeTypes])
unless ranges = HTTPUtils::parse_range_header(req['range'])
- raise BadRequest, "Unrecognized range-spec: \"#{range}\""
+ raise HTTPStatus::BadRequest,
+ "Unrecognized range-spec: \"#{req['range']}\""
end
open(filename, "rb"){|io|
if ranges.size > 1
+ time = Time.now
boundary = "#{time.sec}_#{time.usec}_#{Process::pid}"
body = ''
- ranges.each{|r|
+ ranges.each{|range|
first, last = prepare_range(range, filesize)
next if first < 0
io.pos = first
@@ -92,6 +94,8 @@ module WEBrick
}
raise HTTPStatus::RequestRangeNotSatisfiable if body.empty?
body << "--" << boundary << "--" << CRLF
+ res["content-type"] = "multipart/byteranges; boundary=#{boundary}"
+ res.body = body
elsif range = ranges[0]
first, last = prepare_range(range, filesize)
raise HTTPStatus::RequestRangeNotSatisfiable if first < 0
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index 79ea9d1f47..bae281ca1a 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -167,7 +167,7 @@ module WEBrick
case range_spec
when /^(\d+)-(\d+)/ then $1.to_i .. $2.to_i
when /^(\d+)-/ then $1.to_i .. -1
- when /^(\d+)/ then -($1.to_i) .. -1
+ when /^-(\d+)/ then -($1.to_i) .. -1
else return nil
end
}