1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_range_header):

fix regex for range-spec.

* lib/webrick/httpservlet/filehandler.rb
  (WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content):
  multipart/byteranges response was broken.

* lib/webrick/httpservlet/erbhandler.rb
  (WEBrick::HTTPServlet::ERBHandler#do_GET): should select media type
  by suffix of script filename.

* lib/xmlrpc/server.rb: refine example code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2004-08-13 04:24:16 +00:00
parent 6640f62ad6
commit 747ca59f52
5 changed files with 25 additions and 5 deletions

View file

@ -1,3 +1,18 @@
Fri Aug 13 13:23:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_range_header):
fix regex for range-spec.
* lib/webrick/httpservlet/filehandler.rb
(WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content):
multipart/byteranges response was broken.
* lib/webrick/httpservlet/erbhandler.rb
(WEBrick::HTTPServlet::ERBHandler#do_GET): should select media type
by suffix of script filename.
* lib/xmlrpc/server.rb: refine example code.
Wed Aug 11 17:17:50 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (RPATHFLAG): stop setting RPATHFLAG on Interix.

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -762,7 +762,7 @@ end
end
httpserver = WEBrick::HTTPServer.new(:Port => 8080)
httpserver.mount("RPC2", s)
httpserver.mount("/RPC2", s)
trap("HUP") { httpserver.shutdown } # use 1 instead of "HUP" on Windows
httpserver.start
== Description