Method: WEBrick::HTTPResponse#body

Defined in:
lib/webrick/httpresponse.rb

#bodyObject

Body may be:

  • a String;

  • an IO-like object that responds to #read and #readpartial;

  • a Proc-like object that responds to #call.

In the latter case, either #chunked= should be set to true, or header['content-length'] explicitly provided. Example:

server.mount_proc '/' do |req, res|
  res.chunked = true
  # or
  # res.header['content-length'] = 10
  res.body = proc { |out| out.write(Time.now.to_s) }
end


70
71
72
# File 'lib/webrick/httpresponse.rb', line 70

def body
  @body
end