Rainbows! Rack HTTP server user/dev discussion
 help / Atom feed
* [PATCH] response: convert source arg to path before IO.copy_stream
@ 2015-10-10  1:52 Eric Wong
  0 siblings, 0 replies; 1+ messages in thread
From: Eric Wong @ 2015-10-10  1:52 UTC (permalink / raw)
  To: rainbows-public

This will allow us use the sendfile syscall under Linux on
Ruby which favor #read/#readpartial methods for non-IO objects.
 lib/rainbows/response.rb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb
index 8d0de1d..5a2b0d5 100644
--- a/lib/rainbows/response.rb
+++ b/lib/rainbows/response.rb
@@ -128,6 +128,9 @@ module Rainbows::Response
     unless IO.method_defined?(:trysendfile)
       module CopyStream
         def write_body_file(body, range)
+          # ensure sendfile gets used for SyncClose objects:
+          body = body.to_path if body.respond_to?(:to_path)
           range ? COPY_STREAM.copy_stream(body, self, range[1], range[0]) :
                   COPY_STREAM.copy_stream(body, self)

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-10  1:52 [PATCH] response: convert source arg to path before IO.copy_stream Eric Wong

Rainbows! Rack HTTP server user/dev discussion

Archives are clonable:
	git clone --mirror https://bogomips.org/rainbows-public
	git clone --mirror http://ou63pmih66umazou.onion/rainbows-public

Newsgroups are available over NNTP:

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox