Sha256: ccec4abb7a2b331b50e1b62590be8ffb5bcdfbbdb7d1a545baafeda75a5fb137

Contents?: true

Size: 912 Bytes

Versions: 23

Compression:

Stored size: 912 Bytes

Contents

# -*- encoding: binary -*-
# :enddoc:
# non-portable body handling for Fiber-based concurrency goes here
# this module is required and included in worker processes only
# this is meant to be included _after_ Rainbows::Response::Body
module Rainbows::Fiber::Body # :nodoc:

  # the sendfile 1.1.0+ gem includes IO#trysendfile
  if IO.method_defined?(:trysendfile)
    def write_body_file(body, range)
      sock, n, body = to_io, nil, body_to_io(body)
      offset, count = range ? range : [ 0, body.stat.size ]
      case n = sock.trysendfile(body, offset, count)
      when Integer
        offset += n
        return if 0 == (count -= n)
      when :wait_writable
        kgio_wait_writable
      else # nil
        return
      end while true
      ensure
        close_if_private(body)
    end
  end

  def self.included(klass)
    klass.__send__ :alias_method, :write_body_stream, :write_body_each
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rainbows-5.1.1 lib/rainbows/fiber/body.rb
rainbows-5.1.0 lib/rainbows/fiber/body.rb
rainbows-5.0.0.5.ge717 lib/rainbows/fiber/body.rb
rainbows-5.0.0 lib/rainbows/fiber/body.rb
rainbows-4.7.0 lib/rainbows/fiber/body.rb
rainbows-4.6.2 lib/rainbows/fiber/body.rb
rainbows-4.6.1 lib/rainbows/fiber/body.rb
rainbows-4.6.0.4.g4108 lib/rainbows/fiber/body.rb
rainbows-4.6.0 lib/rainbows/fiber/body.rb
rainbows-4.5.0 lib/rainbows/fiber/body.rb
rainbows-4.4.3 lib/rainbows/fiber/body.rb
rainbows-4.4.2 lib/rainbows/fiber/body.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/fiber/body.rb
rainbows-4.4.1 lib/rainbows/fiber/body.rb
rainbows-4.4.0 lib/rainbows/fiber/body.rb
rainbows-4.3.1 lib/rainbows/fiber/body.rb
rainbows-4.3.0 lib/rainbows/fiber/body.rb
rainbows-4.2.0 lib/rainbows/fiber/body.rb
rainbows-4.1.0 lib/rainbows/fiber/body.rb
rainbows-4.0.0 lib/rainbows/fiber/body.rb