Class: WEBrick::HTTPResponse
- Inherits:
-
Object
- Object
- WEBrick::HTTPResponse
- Defined in:
- lib/webrick/highperformanceserver.rb
Overview
:nodoc:
Instance Method Summary collapse
- #chunked? ⇒ Boolean
- #old_chunked? ⇒ Object
- #old_send_body_io ⇒ Object
-
#send_body_io(socket) ⇒ Object
Copied from WEBrick::HTTPResponse to add sendfile support.
Instance Method Details
#chunked? ⇒ Boolean
10 11 12 |
# File 'lib/webrick/highperformanceserver.rb', line 10 def chunked? return @body.is_a?(File) ? false : @chunked end |
#old_chunked? ⇒ Object
8 |
# File 'lib/webrick/highperformanceserver.rb', line 8 alias old_chunked? chunked? |
#old_send_body_io ⇒ Object
7 |
# File 'lib/webrick/highperformanceserver.rb', line 7 alias old_send_body_io send_body_io |
#send_body_io(socket) ⇒ Object
Copied from WEBrick::HTTPResponse to add sendfile support.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webrick/highperformanceserver.rb', line 17 def send_body_io(socket) socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1 # HACK yuck if @request_method == "HEAD" # do nothing elsif @body.kind_of? File socket.sendfile @body elsif chunked? while buf = @body.read(BUFSIZE) next if buf.empty? data = "" data << format("%x", buf.size) << CRLF data << buf << CRLF _write_data(socket, data) @sent_size += buf.size end _write_data(socket, "0#{CRLF}#{CRLF}") else size = @header['content-length'].to_i _send_file(socket, @body, 0, size) @sent_size = size end ensure @body.close end |