Sha256: f9ad9d60f5a7728774184e336512bcb5216fd7db6f5f55d4b20125ce0634d8be

Contents?: true

Size: 956 Bytes

Versions: 10

Compression:

Stored size: 956 Bytes

Contents

module Typhoeus
  class Request

    # This module contians the logic for response streaming.
    module Streamable

      # Set on_body callback.
      #
      # This callback will be called each time a portion of the body is read from the socket.
      # Setting an on_body callback will cause the response body to be empty.
      #
      # @example Set on_body.
      #   request.on_body { |response, body_chunk| puts "Got #{body_chunk.bytesize} bytes" }
      #
      # @param [ Block ] block The block to execute.
      #
      # @yield [ Typhoeus::Response, String ]
      #
      # @return [ Array<Block> ] All on_body blocks.
      def on_body(&block)
        @on_body ||= []
        @on_body << block if block_given?
        @on_body
      end

      # Is this request using streaming?
      #
      # @return [ Boolean ] True if any on_body blocks have been set.
      def streaming?
        @on_body && @on_body.any?
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/typhoeus-0.8.0/lib/typhoeus/request/streamable.rb
typhoeus-0.8.0 lib/typhoeus/request/streamable.rb
typhoeus-0.7.3 lib/typhoeus/request/streamable.rb
typhoeus-0.7.2 lib/typhoeus/request/streamable.rb
typhoeus-0.7.1 lib/typhoeus/request/streamable.rb
typhoeus-0.7.0 lib/typhoeus/request/streamable.rb
typhoeus-0.7.0.pre1 lib/typhoeus/request/streamable.rb
typhoeus-0.6.9 lib/typhoeus/request/streamable.rb
typhoeus-0.6.8 lib/typhoeus/request/streamable.rb
typhoeus-0.6.7 lib/typhoeus/request/streamable.rb