Sha256: 83cc10c1b35954eba895202879e9313b6d393e9b07128a40eb94d00e7d8c5723

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

class HttpOptions
  attr_reader :uri, :method, :host, :port, :options

  def initialize(method, uri, options)
    raise ArgumentError, "invalid request path" unless /^\// === uri.path

    @options = options
    @method = method.to_s.upcase
    @uri = uri

    if proxy = options[:proxy]
      @host = proxy[:host]
      @port = proxy[:port]
    else
      @host = uri.host
      @port = uri.port
    end

    @options[:timeout]    ||= 10  # default connect & inactivity timeouts
    @options[:redirects]  ||= 0   # default number of redirects to follow

    # Make sure the ports are set as Addressable::URI doesn't
    # set the port if it isn't there
    if uri.scheme == "https"
      @uri.port ||= 443
      @port     ||= 443
    else
      @uri.port ||= 80
      @port     ||= 80
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-http-request-0.2.10 lib/em-http/http_options.rb
em-http-request-0.2.9 lib/em-http/http_options.rb