Project

General

Profile

Bug #559 ยป patch.diff

lemon (raspberry lemon), 09/14/2008 02:46 AM

View differences:

lib/webrick/httpproxy.rb (working copy)
while fds = IO::select([ua, os])
if fds[0].member?(ua)
buf = ua.sysread(1024);
@logger.debug("CONNECT: #{buf.size} byte from User-Agent")
@logger.debug("CONNECT: #{buf.bytesize} byte from User-Agent")
os.syswrite(buf)
elsif fds[0].member?(os)
buf = os.sysread(1024);
@logger.debug("CONNECT: #{buf.size} byte from #{host}:#{port}")
@logger.debug("CONNECT: #{buf.bytesize} byte from #{host}:#{port}")
ua.syswrite(buf)
end
end
lib/webrick/httpservlet/filehandler.rb (working copy)
def do_GET(req, res)
st = File::stat(@local_path)
mtime = st.mtime
res['etag'] = sprintf("%x-%x-%x", st.ino, st.size, st.mtime.to_i)
res['etag'] = sprintf("%x-%x-%x", st.ino, st.bytesize, st.mtime.to_i)
if not_modified?(req, res, mtime, res['etag'])
res.body = ''
raise HTTPStatus::NotModified
elsif req['range']
make_partial_content(req, res, @local_path, st.size)
make_partial_content(req, res, @local_path, st.bytesize)
raise HTTPStatus::PartialContent
else
mtype = HTTPUtils::mime_type(@local_path, @config[:MimeTypes])
res['content-type'] = mtype
res['content-length'] = st.size
res['content-length'] = st.bytesize
res['last-modified'] = mtime.httpdate
res.body = open(@local_path, "rb")
end
......
"Unrecognized range-spec: \"#{req['range']}\""
end
open(filename, "rb"){|io|
if ranges.size > 1
if ranges.bytesize > 1
time = Time.now
boundary = "#{time.sec}_#{time.usec}_#{Process::pid}"
body = ''
......
path = res.filename + basename
if File.file?(path)
return basename
elsif langs.size > 0
elsif langs.bytesize > 0
req.accept_language.each{|lang|
path_with_lang = path + ".#{lang}"
if langs.member?(lang) && File.file?(path_with_lang)
......
elsif st.directory?
[ name + "/", st.mtime, -1 ]
else
[ name, st.mtime, st.size ]
[ name, st.mtime, st.bytesize ]
end
}
list.compact!
......
list.each{ |name, time, size|
if name == ".."
dname = "Parent Directory"
elsif name.size > 25
elsif name.bytesize > 25
dname = name.sub(/^(.{23})(?:.*)/, '\1..')
else
dname = name
end
s = " <A HREF=\"#{HTTPUtils::escape(name)}\">#{dname}</A>"
s << " " * (30 - dname.size)
s << " " * (30 - dname.bytesize)
s << (time ? time.strftime("%Y/%m/%d %H:%M ") : " " * 22)
s << (size >= 0 ? size.to_s : "-") << "\n"
res.body << s
lib/webrick/httpservlet/cgihandler.rb (working copy)
end
dump = Marshal.dump(meta)
cgi_in.write("%8d" % cgi_out.path.size)
cgi_in.write("%8d" % cgi_out.path.bytesize)
cgi_in.write(cgi_out.path)
cgi_in.write("%8d" % cgi_err.path.size)
cgi_in.write("%8d" % cgi_err.path.bytesize)
cgi_in.write(cgi_err.path)
cgi_in.write("%8d" % dump.size)
cgi_in.write("%8d" % dump.bytesize)
cgi_in.write(dump)
if req.body and req.body.size > 0
if req.body and req.body.bytesize > 0
cgi_in.write(req.body)
end
ensure
......
data = cgi_out.read
cgi_out.close(true)
if errmsg = cgi_err.read
if errmsg.size > 0
if errmsg.bytesize > 0
@logger.error("CGIHandler: #{@script_filename}:\n" + errmsg)
end
end
lib/webrick/httpservlet/abstract.rb (working copy)
def redirect_to_directory_uri(req, res)
if req.path[-1] != ?/
location = WEBrick::HTTPUtils.escape_path(req.path + "/")
if req.query_string && req.query_string.size > 0
if req.query_string && req.query_string.bytesize > 0
location << "?" << req.query_string
end
res.set_redirect(HTTPStatus::MovedPermanently, location)
lib/webrick/httpservlet/cgi_runner.rb (working copy)
while size > 0
tmp = io.sysread(size)
buf << tmp
size -= tmp.size
size -= tmp.bytesize
end
return buf
end
lib/webrick/httprequest.rb (working copy)
def read_request_line(socket)
@request_line = read_line(socket, 1024) if socket
if @request_line.size >= 1024 and @request_line[-1, 1] != LF
if @request_line.bytesize >= 1024 and @request_line[-1, 1] != LF
raise HTTPStatus::RequestURITooLarge
end
@request_time = Time.now
......
elsif self["host"]
pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/n
host, port = *self['host'].scan(pattern)[0]
elsif @addr.size > 0
elsif @addr.bytesize > 0
host, port = @addr[2], @addr[1]
else
host, port = @config[:ServerName], @config[:Port]
......
while @remaining_size > 0
sz = [@buffer_size, @remaining_size].min
break unless buf = read_data(socket, sz)
@remaining_size -= buf.size
@remaining_size -= buf.bytesize
block.call(buf)
end
if @remaining_size > 0 && @socket.eof?
......
chunk_size, = read_chunk_size(socket)
while chunk_size > 0
data = read_data(socket, chunk_size) # read chunk-data
if data.nil? || data.size != chunk_size
if data.nil? || data.bytesize != chunk_size
raise BadRequest, "bad chunk data size."
end
read_line(socket) # skip CRLF
lib/webrick/httpresponse.rb (working copy)
@header.delete('content-length')
elsif @header['content-length'].nil?
unless @body.is_a?(IO)
@header['content-length'] = @body ? @body.size : 0
@header['content-length'] = @body ? @body.bytesize : 0
end
end
......
while buf = @body.read(@buffer_size)
next if buf.empty?
data = ""
data << format("%x", buf.size) << CRLF
data << format("%x", buf.bytesize) << CRLF
data << buf << CRLF
_write_data(socket, data)
@sent_size += buf.size
@sent_size += buf.bytesize
end
_write_data(socket, "0#{CRLF}#{CRLF}")
else
......
if @request_method == "HEAD"
# do nothing
elsif chunked?
remain = body ? @body.size : 0
remain = body ? @body.bytesize : 0
while buf = @body[@sent_size, @buffer_size]
break if buf.empty?
data = ""
data << format("%x", buf.size) << CRLF
data << format("%x", buf.bytesize) << CRLF
data << buf << CRLF
_write_data(socket, data)
@sent_size += buf.size
@sent_size += buf.bytesize
end
_write_data(socket, "0#{CRLF}#{CRLF}")
else
if @body && @body.size > 0
if @body && @body.bytesize > 0
_write_data(socket, @body)
@sent_size = @body.size
@sent_size = @body.bytesize
end
end
end
......
while offset > 0
sz = @buffer_size < size ? @buffer_size : size
buf = input.read(sz)
offset -= buf.size
offset -= buf.bytesize
end
if size == 0
......
sz = @buffer_size < size ? @buffer_size : size
buf = input.read(sz)
_write_data(output, buf)
size -= buf.size
size -= buf.bytesize
end
end
end
lib/webrick/httpauth/digestauth.rb (working copy)
def split_param_value(string)
ret = {}
while string.size != 0
while string.bytesize != 0
case string
when /^\s*([\w\-\.\*\%\!]+)=\s*\"((\\.|[^\"])*)\"\s*,?/
key = $1
lib/webrick/utils.rb (working copy)
"abcdefghijklmnopqrstuvwxyz"
def random_string(len)
rand_max = RAND_CHARS.size
rand_max = RAND_CHARS.bytesize
ret = ""
len.times{ ret << RAND_CHARS[rand(rand_max)] }
ret
    (1-1/1)