Module: HTTP::Chainable

### Home Classes Methods

### In Files

- lib/http/chainable.rb

### Methods

- #accept
- #auth
- #basic_auth
- #connect
- #default_headers
- #default_headers=
- #default_options
- #default_options=
- #delete
- #follow
- #get
- #head
- #options
- #patch
- #post
- #put
- #request
- #stream
- #through
- #trace
- #via
- #with
- #with_follow
- #with_headers

### Class/Module Index

Quicksearch

- HTTP
- HTTP::Chainable
- HTTP::Client
- HTTP::Error
- HTTP::Headers
- HTTP::Headers::Mixin
- HTTP::MimeType
- HTTP::MimeType::Adapter
- HTTP::MimeType::JSON
- HTTP::Options
- HTTP::Redirector
- HTTP::Redirector::EndlessRedirectError
- HTTP::Redirector::TooManyRedirectsError
- HTTP::Request
- HTTP::Request::UnsupportedMethodError
- HTTP::Request::UnsupportedSchemeError
- HTTP::Request::Writer
- HTTP::RequestError
- HTTP::Response
- HTTP::Response::Body
- HTTP::Response::Parser
- HTTP::Response::Status
- HTTP::ResponseError
- HTTP::StateError
- Object

No matching classes.

# HTTP::Chainable

### Public Instance Methods

accept(type) click to toggle source

Accept the given MIME type(s) @param type

    # File lib/http/chainable.rb, line 119
    def accept(type)
      with :accept => MimeType.normalize(type)
    end

auth(value, opts = nil) click to toggle source

Make a request with the given Authorization header @param [to_s] value Authorization header value

    # File lib/http/chainable.rb, line 125
    def auth(value, opts = nil)
      # shim for deprecated auth(:basic, opts).
      # will be removed in 0.8.0
      return basic_auth(opts) if :basic == value
      with :authorization => value.to_s
    end

basic_auth(opts) click to toggle source

Make a request with the given Basic authorization header @see tools.ietf.org/html/rfc2617 @param [fetch] opts @option opts [to_s] :user @option opts [to_s] :pass

    # File lib/http/chainable.rb, line 137
    def basic_auth(opts)
      user = opts.fetch :user
      pass = opts.fetch :pass

      auth('Basic ' << Base64.strict_encode64("#{user}:#{pass}"))
    end

connect(uri, options = {}) click to toggle source

Convert to a transparent TCP/IP tunnel @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 57
    def connect(uri, options = {})
      request :connect, uri, options
    end

default_headers() click to toggle source

Get headers of HTTP options

    # File lib/http/chainable.rb, line 158
    def default_headers
      default_options.headers
    end

default_headers=(headers) click to toggle source

Set headers of HTTP options @param headers

    # File lib/http/chainable.rb, line 164
    def default_headers=(headers)
      @default_options = default_options.dup do |opts|
        opts.headers = headers
      end
    end

default_options() click to toggle source

Get options for HTTP @return [HTTP::Options]

    # File lib/http/chainable.rb, line 146
    def default_options
      @default_options ||= HTTP::Options.new
    end

default_options=(opts) click to toggle source

Set options for HTTP @param opts @return [HTTP::Options]

    # File lib/http/chainable.rb, line 153
    def default_options=(opts)
      @default_options = HTTP::Options.new(opts)
    end

delete(uri, options = {}) click to toggle source

Delete a resource @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 36
    def delete(uri, options = {})
      request :delete, uri, options
    end

follow(opts = true) click to toggle source

Make client follow redirects. @param opts @return [HTTP::Client] @see Redirector#initialize

    # File lib/http/chainable.rb, line 102
    def follow(opts = true)
      branch default_options.with_follow opts
    end

Also aliased as: with_follow
get(uri, options = {}) click to toggle source

Get a resource @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 15
    def get(uri, options = {})
      request :get, uri, options
    end

head(uri, options = {}) click to toggle source

Request a get sans response body @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 8
    def head(uri, options = {})
      request :head, uri, options
    end

options(uri, options = {}) click to toggle source

Return the methods supported on the given URI @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 50
    def options(uri, options = {})
      request :options, uri, options
    end

patch(uri, options = {}) click to toggle source

Apply partial modifications to a resource @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 64
    def patch(uri, options = {})
      request :patch, uri, options
    end

post(uri, options = {}) click to toggle source

Post to a resource @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 22
    def post(uri, options = {})
      request :post, uri, options
    end

put(uri, options = {}) click to toggle source

Put to a resource @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 29
    def put(uri, options = {})
      request :put, uri, options
    end

request(verb, uri, options = {}) click to toggle source

Make an HTTP request with the given verb @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 71
    def request(verb, uri, options = {})
      branch(options).request verb, uri
    end

stream() click to toggle source

Alias for with_response(:object)

    # File lib/http/chainable.rb, line 94
    def stream
      with_response(:object)
    end

through(*proxy) click to toggle source
Alias for: via
trace(uri, options = {}) click to toggle source

Echo the request back to the client @param uri @option options [Hash]

    # File lib/http/chainable.rb, line 43
    def trace(uri, options = {})
      request :trace, uri, options
    end

via(*proxy) click to toggle source

Make a request through an HTTP proxy @param [Array] proxy @raise [Request::Error] if HTTP proxy is invalid

    # File lib/http/chainable.rb, line 78
    def via(*proxy)
      proxy_hash = {}
      proxy_hash[:proxy_address]  = proxy[0] if proxy[0].is_a?(String)
      proxy_hash[:proxy_port]     = proxy[1] if proxy[1].is_a?(Integer)
      proxy_hash[:proxy_username] = proxy[2] if proxy[2].is_a?(String)
      proxy_hash[:proxy_password] = proxy[3] if proxy[3].is_a?(String)

      if [2, 4].include?(proxy_hash.keys.size)
        branch default_options.with_proxy(proxy_hash)
      else
        fail(RequestError, "invalid HTTP proxy: #{proxy_hash}")
      end
    end

Also aliased as: through
with(headers) click to toggle source
Alias for: with_headers
with_follow(opts = true) click to toggle source

@deprecated @see follow

Alias for: follow
with_headers(headers) click to toggle source

Make a request with the given headers @param headers

    # File lib/http/chainable.rb, line 112
    def with_headers(headers)
      branch default_options.with_headers(headers)
    end

Also aliased as: with

[Validate]

Generated with the Darkfish Rdoc Generator 2.