Class: HTTP::Timeout::Global

### Home Classes Methods

### In Files

- lib/http/timeout/global.rb

### Parent

PerOperation

### Methods

- ::new
- #<<
- #connect
- #connect_ssl
- #readpartial
- #reset_counter
- #write

### Class/Module Index

Quicksearch

- HTTP
- HTTP::Cache
- HTTP::Cache::Headers
- HTTP::Cache::NullCache
- HTTP::Cache::NullLogger
- HTTP::CacheError
- HTTP::Chainable
- HTTP::Client
- HTTP::Connection
- HTTP::Error
- HTTP::Headers
- HTTP::Headers::Mixin
- HTTP::InvalidHeaderNameError
- HTTP::MimeType
- HTTP::MimeType::Adapter
- HTTP::MimeType::JSON
- HTTP::Options
- HTTP::Redirector
- HTTP::Redirector::EndlessRedirectError
- HTTP::Redirector::TooManyRedirectsError
- HTTP::Request
- HTTP::Request::Caching
- HTTP::Request::UnsupportedMethodError
- HTTP::Request::UnsupportedSchemeError
- HTTP::Request::Writer
- HTTP::RequestError
- HTTP::Response
- HTTP::Response::Body
- HTTP::Response::Caching
- HTTP::Response::IoBody
- HTTP::Response::Parser
- HTTP::Response::Status
- HTTP::Response::StringBody
- HTTP::ResponseError
- HTTP::StateError
- HTTP::Timeout
- HTTP::Timeout::Global
- HTTP::Timeout::Null
- HTTP::Timeout::PerOperation
- HTTP::TimeoutError
- HTTP::URI
- Object

No matching classes.

# HTTP::Timeout::Global

### Attributes

time_left[R]
total_timeout[R]

### Public Class Methods

new(*args) click to toggle source

    # File lib/http/timeout/global.rb, line 6
    def initialize(*args)
      super

      reset_counter
    end

### Public Instance Methods

<<(data) click to toggle source
Alias for: write
connect(socket_class, host, port) click to toggle source

    # File lib/http/timeout/global.rb, line 16
    def connect(socket_class, host, port)
      reset_timer
      ::Timeout.timeout(time_left, TimeoutError) do
        @socket = socket_class.open(host, port)
      end

      log_time
    end

connect_ssl() click to toggle source

    # File lib/http/timeout/global.rb, line 25
    def connect_ssl
      reset_timer

      begin
        socket.connect_nonblock
      rescue IO::WaitReadable
        IO.select([socket], nil, nil, time_left)
        log_time
        retry
      rescue IO::WaitWritable
        IO.select(nil, [socket], nil, time_left)
        log_time
        retry
      end
    end

readpartial(size) click to toggle source

Read from the socket

    # File lib/http/timeout/global.rb, line 42
    def readpartial(size)
      reset_timer

      begin
        socket.read_nonblock(size)
      rescue IO::WaitReadable
        IO.select([socket], nil, nil, time_left)
        log_time
        retry
      end
    end

reset_counter() click to toggle source

    # File lib/http/timeout/global.rb, line 12
    def reset_counter
      @time_left = @total_timeout = connect_timeout + read_timeout + write_timeout
    end

write(data) click to toggle source

Write to the socket

    # File lib/http/timeout/global.rb, line 55
    def write(data)
      reset_timer

      begin
        socket << data
      rescue IO::WaitWritable
        IO.select(nil, [socket], nil, time_left)
        log_time
        retry
      end
    end

Also aliased as: <<

[Validate]

Generated with the Darkfish Rdoc Generator 2.