diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb index 94f385f1dd..33f1542731 100644 --- a/lib/webrick/cgi.rb +++ b/lib/webrick/cgi.rb @@ -265,6 +265,10 @@ module WEBrick @out_port << data end + def write(data) + @out_port.write(data) + end + def cert return nil unless defined?(OpenSSL) if pem = @env["SSL_SERVER_CERT"] diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index d76310f935..eddd3388ed 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -293,7 +293,7 @@ module WEBrick data << "Set-Cookie: " << cookie.to_s << CRLF } data << CRLF - _write_data(socket, data) + socket.write(data) end end @@ -401,14 +401,14 @@ module WEBrick @body.readpartial(@buffer_size, buf) size = buf.bytesize data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" - _write_data(socket, data) + socket.write(data) data.clear @sent_size += size rescue EOFError break end while true buf.clear - _write_data(socket, "0#{CRLF}#{CRLF}") + socket.write("0#{CRLF}#{CRLF}") else size = @header['content-length'].to_i _send_file(socket, @body, 0, size) @@ -429,13 +429,13 @@ module WEBrick size = buf.bytesize data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" buf.clear - _write_data(socket, data) + socket.write(data) @sent_size += size end - _write_data(socket, "0#{CRLF}#{CRLF}") + socket.write("0#{CRLF}#{CRLF}") else if @body && @body.bytesize > 0 - _write_data(socket, @body) + socket.write(@body) @sent_size = @body.bytesize end end @@ -446,7 +446,7 @@ module WEBrick # do nothing elsif chunked? @body.call(ChunkedWrapper.new(socket, self)) - _write_data(socket, "0#{CRLF}#{CRLF}") + socket.write("0#{CRLF}#{CRLF}") else size = @header['content-length'].to_i @body.call(socket) @@ -466,7 +466,7 @@ module WEBrick @resp.instance_eval { size = buf.bytesize data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" - _write_data(socket, data) + socket.write(data) data.clear @sent_size += size } @@ -483,18 +483,19 @@ module WEBrick if size == 0 while buf = input.read(@buffer_size) - _write_data(output, buf) + output.write(buf) end else while size > 0 sz = @buffer_size < size ? @buffer_size : size buf = input.read(sz) - _write_data(output, buf) + output.write(buf) size -= buf.bytesize end end end + # preserved for compatibility with some 3rd-party handlers def _write_data(socket, data) socket << data end