HTTP::Chainable

Public Instance Methods

accept(type) click to toggle source

Accept the given MIME type(s)

# File lib/http/chainable.rb, line 93
def accept(type)
  if type.is_a? String
    with :accept => type
  else
    mime_type = HTTP::MimeType[type]
    raise ArgumentError, "unknown MIME type: #{type}" unless mime_type
    with :accept => mime_type.type
  end
end
connect(uri, options = {}) click to toggle source

Convert to a transparent TCP/IP tunnel

# File lib/http/chainable.rb, line 39
def connect(uri, options = {})
  request :connect, uri, options
end
default_callbacks() click to toggle source
# File lib/http/chainable.rb, line 121
def default_callbacks
  default_options.callbacks
end
default_callbacks=(callbacks) click to toggle source
# File lib/http/chainable.rb, line 125
def default_callbacks=(callbacks)
  @default_options = default_options.dup do |opts|
    opts.callbacks = callbacks
  end
end
default_headers() click to toggle source
# File lib/http/chainable.rb, line 111
def default_headers
  default_options.headers
end
default_headers=(headers) click to toggle source
# File lib/http/chainable.rb, line 115
def default_headers=(headers)
  @default_options = default_options.dup do |opts|
    opts.headers = headers
  end
end
default_options() click to toggle source
# File lib/http/chainable.rb, line 103
def default_options
  @default_options ||= HTTP::Options.new
end
default_options=(opts) click to toggle source
# File lib/http/chainable.rb, line 107
def default_options=(opts)
  @default_options = HTTP::Options.new(opts)
end
delete(uri, options = {}) click to toggle source

Delete a resource

# File lib/http/chainable.rb, line 24
def delete(uri, options = {})
  request :delete, uri, options
end
get(uri, options = {}) click to toggle source

Get a resource

# File lib/http/chainable.rb, line 9
def get(uri, options = {})
  request :get, uri, options
end
head(uri, options = {}) click to toggle source

Request a get sans response body

# File lib/http/chainable.rb, line 4
def head(uri, options = {})
  request :head, uri, options
end
on(event, &block) click to toggle source

Make a request invoking the given event callbacks

# File lib/http/chainable.rb, line 54
def on(event, &block)
  branch default_options.with_callback(event, block)
end
options(uri, options = {}) click to toggle source

Return the methods supported on the given URI

# File lib/http/chainable.rb, line 34
def options(uri, options = {})
  request :options, uri, options
end
patch(uri, options = {}) click to toggle source

Apply partial modifications to a resource

# File lib/http/chainable.rb, line 44
def patch(uri, options = {})
  request :patch, uri, options
end
post(uri, options = {}) click to toggle source

Post to a resource

# File lib/http/chainable.rb, line 14
def post(uri, options = {})
  request :post, uri, options
end
put(uri, options = {}) click to toggle source

Put to a resource

# File lib/http/chainable.rb, line 19
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

# File lib/http/chainable.rb, line 49
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 80
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

# File lib/http/chainable.rb, line 29
def trace(uri, options = {})
  request :trace, uri, options
end
via(*proxy) click to toggle source

Make a request through an HTTP proxy

# File lib/http/chainable.rb, line 59
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 proxy_hash.keys.size >=2
    branch default_options.with_proxy(proxy_hash)
  else
    raise ArgumentError, "invalid HTTP proxy: #{proxy_hash}"
  end
end
Also aliased as: through
with(headers) click to toggle source
Alias for: with_headers
with_follow(follow) click to toggle source
# File lib/http/chainable.rb, line 82
def with_follow(follow)
  branch default_options.with_follow(follow)
end
with_headers(headers) click to toggle source

Make a request with the given headers

# File lib/http/chainable.rb, line 87
def with_headers(headers)
  branch default_options.with_headers(headers)
end
Also aliased as: with
with_response(response_type) click to toggle source

Specify the kind of response to return (:auto, :object, :body, :parsed_body)

# File lib/http/chainable.rb, line 75
def with_response(response_type)
  branch default_options.with_response(response_type)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.