From f7cf5416e471cd34153058952063da3457468e58 Mon Sep 17 00:00:00 2001 From: zverok Date: Sat, 26 Oct 2019 13:27:17 +0300 Subject: [ruby/webrick] Document HTTPResponse#body callable option https://github.com/ruby/webrick/commit/d51836d03d --- lib/webrick/httpresponse.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib') 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 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 attr_accessor :body -- cgit v1.2.3