Skip to content

Commit

Permalink
[ruby/webrick] Document HTTPResponse#body callable option
Browse files Browse the repository at this point in the history
  • Loading branch information
zverok authored and hsbt committed Nov 30, 2019
1 parent ea4272d commit f7cf541
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/webrick/httpresponse.rb
Expand Up @@ -51,8 +51,21 @@ class InvalidHeader < StandardError
attr_accessor :reason_phrase

##
# Body may be a String or IO-like object that responds to #read and
# #readpartial.
# 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 <code>header['content-length']</code> 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

attr_accessor :body

Expand Down

0 comments on commit f7cf541

Please sign in to comment.