[前][次][番号順一覧][スレッド一覧]

ruby-changes:58983

From: zverok <ko1@a...>
Date: Sat, 30 Nov 2019 17:53:46 +0900 (JST)
Subject: [ruby-changes:58983] f7cf5416e4 (master): [ruby/webrick] Document HTTPResponse#body callable option

https://git.ruby-lang.org/ruby.git/commit/?id=f7cf5416e4

From f7cf5416e471cd34153058952063da3457468e58 Mon Sep 17 00:00:00 2001
From: zverok <zverok.offline@g...>
Date: Sat, 26 Oct 2019 13:27:17 +0300
Subject: [ruby/webrick] Document HTTPResponse#body callable option

https://github.com/ruby/webrick/commit/d51836d03d

diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 121f5e6..9942a59 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -51,8 +51,21 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpresponse.rb#L51
     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
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]