Class: HttpClientOptions

### Home Classes Methods

### In Files

- lib/em-http/http_client_options.rb

### Parent

Object

### Methods

- ::new
- #follow_redirect?
- #no_body?
- #set_uri
- #ssl?

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine::HTTPMethods
- EventMachine::HttpClient
- EventMachine::HttpClient::CookieJar
- EventMachine::HttpConnection
- EventMachine::HttpDecoders
- EventMachine::HttpDecoders::Base
- EventMachine::HttpDecoders::DecoderError
- EventMachine::HttpDecoders::Deflate
- EventMachine::HttpDecoders::GZip
- EventMachine::HttpDecoders::GZipHeader
- EventMachine::HttpEncoding
- EventMachine::HttpRequest
- EventMachine::HttpResponseHeader
- EventMachine::HttpStatus
- EventMachine::HttpStubConnection
- EventMachine::Middleware
- EventMachine::Middleware::DigestAuth
- EventMachine::Middleware::JSONResponse
- EventMachine::Middleware::OAuth
- EventMachine::Middleware::OAuth2
- EventMachine::MultiRequest
- HttpClientOptions
- HttpConnectionOptions
- String

No matching classes.

# HttpClientOptions

### Attributes

body[R]
decoding[R]
file[R]
followed[RW]
headers[R]
host[R]
keepalive[R]
method[R]
pass_cookies[R]
path[R]
port[R]
query[R]
redirects[RW]
uri[R]

### Public Class Methods

new(uri, options, method) click to toggle source

    # File lib/em-http/http_client_options.rb, line 8
    def initialize(uri, options, method)
      @keepalive = options[:keepalive] || false  # default to single request per connection
      @redirects = options[:redirects] ||= 0     # default number of redirects to follow
      @followed  = options[:followed]  ||= 0     # keep track of number of followed requests

      @method   = method.to_s.upcase
      @headers  = options[:head] || {}
      @query    = options[:query]

      @file     = options[:file]
      @body     = options[:body]

      @pass_cookies = options.fetch(:pass_cookies, true)  # pass cookies between redirects
      @decoding     = options.fetch(:decoding, true)      # auto-decode compressed response

      set_uri(uri, options[:path])
    end

### Public Instance Methods

follow_redirect?() click to toggle source

    # File lib/em-http/http_client_options.rb, line 27
    def follow_redirect?; @followed < @redirects; end

no_body?() click to toggle source

    # File lib/em-http/http_client_options.rb, line 29
    def no_body?; @method == "HEAD"; end

set_uri(uri, path = nil) click to toggle source

    # File lib/em-http/http_client_options.rb, line 31
    def set_uri(uri, path = nil)
      uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s)
      uri.path = path if path
      uri.path = '/' if uri.path.empty?

      @uri = uri
      @path = uri.path
      @host = uri.host
      @port = uri.port

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

    end

ssl?() click to toggle source

    # File lib/em-http/http_client_options.rb, line 28
    def ssl?; @uri.scheme == "https" || @uri.port == 443; end

[Validate]

Generated with the Darkfish Rdoc Generator 2.