module HTTP::Chainable
def accept(type)
def accept(type) with :accept => MimeType.normalize(type) end
def auth(*args)
def auth(*args) value = case args.count when 1 then args.first when 2 then AuthorizationHeader.build(*args) else fail ArgumentError, "wrong number of arguments (#{args.count} for 1..2)" end with :authorization => value.to_s end
def branch(options)
def branch(options) HTTP::Client.new(options) end
def connect(uri, options = {})
def connect(uri, options = {}) request :connect, uri, options end
def default_callbacks
def default_callbacks default_options.callbacks end
def default_callbacks=(callbacks)
def default_callbacks=(callbacks) @default_options = default_options.dup do |opts| opts.callbacks = callbacks end end
def default_headers
def default_headers default_options.headers end
def default_headers=(headers)
def default_headers=(headers) @default_options = default_options.dup do |opts| opts.headers = headers end end
def default_options
def default_options @default_options ||= HTTP::Options.new end
def default_options=(opts)
def default_options=(opts) @default_options = HTTP::Options.new(opts) end
def delete(uri, options = {})
def delete(uri, options = {}) request :delete, uri, options end
def get(uri, options = {})
def get(uri, options = {}) request :get, uri, options end
def head(uri, options = {})
def head(uri, options = {}) request :head, uri, options end
def options(uri, options = {})
def options(uri, options = {}) request :options, uri, options end
def patch(uri, options = {})
def patch(uri, options = {}) request :patch, uri, options end
def post(uri, options = {})
def post(uri, options = {}) request :post, uri, options end
def put(uri, options = {})
def put(uri, options = {}) request :put, uri, options end
def request(verb, uri, options = {})
def request(verb, uri, options = {}) branch(options).request verb, uri end
def stream
def stream with_response(:object) end
def trace(uri, options = {})
def trace(uri, options = {}) request :trace, uri, options end
def via(*proxy)
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
def with_follow(follow)
def with_follow(follow) branch default_options.with_follow(follow) end
def with_headers(headers)
def with_headers(headers) branch default_options.with_headers(headers) end