class Raindrops::Middleware::Proxy - raindrops-0.19.0 Documentation

# class Raindrops::Middleware::Proxy

This class is used by Raindrops::Middleware to proxy application response bodies. There should be no need to use it directly.

### Public Class Methods

new(body, stats) click to toggle source

    # File lib/raindrops/middleware/proxy.rb, line 5
    def initialize(body, stats)
      @body, @stats = body, stats
    end

### Public Instance Methods

close() click to toggle source

the Rack server should call this after each (usually ensure-d)

    # File lib/raindrops/middleware/proxy.rb, line 15
    def close
      @stats.decr_writing
      @body.close if @body.respond_to?(:close)
    end

each() { |x| ... } click to toggle source

yield to the Rack server here for writing

    # File lib/raindrops/middleware/proxy.rb, line 10
    def each
      @body.each { |x| yield x }
    end

method_missing(*args, &block) click to toggle source

Avoid breaking users of non-standard extensions (e.g. body) Rack::BodyProxy does the same.

    # File lib/raindrops/middleware/proxy.rb, line 36
    def method_missing(*args, &block)
      @body.__send__(*args, &block)
    end

respond_to?(m, include_all = false) click to toggle source

Rack servers use `respond_to?` to check for the presence of `close` and `to_path` methods.

    # File lib/raindrops/middleware/proxy.rb, line 29
    def respond_to?(m, include_all = false)
      m = m.to_sym
      :close == m || @body.respond_to?(m, include_all)
    end

to_path() click to toggle source

Some Rack servers can optimize response processing if it responds to `to_path` via the sendfile(2) system call, we proxy `to_path` to the underlying body if possible.

    # File lib/raindrops/middleware/proxy.rb, line 23
    def to_path
      @body.to_path
    end