Sha256: e4359b2102904cbbc9a14917ba89047a32d6d089a0914e85b1a8478ddecafcb3

Contents?: true

Size: 966 Bytes

Versions: 11

Compression:

Stored size: 966 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?
        defined?(@on_body) && @on_body.any?
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/streamable.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/streamable.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.3.0/lib/typhoeus/request/streamable.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/streamable.rb
typhoeus-1.3.0 lib/typhoeus/request/streamable.rb
typhoeus-1.1.2 lib/typhoeus/request/streamable.rb
typhoeus-1.1.1 lib/typhoeus/request/streamable.rb
typhoeus-1.1.0 lib/typhoeus/request/streamable.rb
typhoeus-1.0.2 lib/typhoeus/request/streamable.rb
typhoeus-1.0.1 lib/typhoeus/request/streamable.rb
typhoeus-1.0.0 lib/typhoeus/request/streamable.rb