summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorzverok <zverok.offline@gmail.com>2019-10-26 13:27:17 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-30 17:47:49 +0900
commitf7cf5416e471cd34153058952063da3457468e58 (patch)
treeee2c8cba85aedf2f3d75d2ddad56fd33b3966b45 /lib
parentea4272d02b02719e266c7cf30141e6275e38f9a7 (diff)
[ruby/webrick] Document HTTPResponse#body callable option
https://github.com/ruby/webrick/commit/d51836d03d
Diffstat (limited to 'lib')
-rw-r--r--lib/webrick/httpresponse.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 121f5e6464..9942a59714 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -51,8 +51,21 @@ module WEBrick
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