From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS16276 92.222.0.0/16 X-Spam-Status: No, score=-2.1 required=3.0 tests=AWL,BAYES_00,RCVD_IN_XBL shortcircuit=no autolearn=no version=3.3.2 X-Original-To: rainbows-public@bogomips.org Received: from 80x24.org (relay2.tor.maximilian-jacobsen.com [92.222.113.177]) by dcvr.yhbt.net (Postfix) with ESMTP id A41DC203FA for ; Sat, 10 Oct 2015 01:53:00 +0000 (UTC) From: Eric Wong To: rainbows-public@bogomips.org Subject: [PATCH] response: convert source arg to path before IO.copy_stream Date: Sat, 10 Oct 2015 01:52:58 +0000 Message-Id: <20151010015258.19805-1-e@80x24.org> List-Id: 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) end -- EW