Accept the given MIME type(s)
# File lib/http/chainable.rb, line 94 def accept(type) with :accept => MimeType.normalize(type) end
Make a request with the given Authorization header
# File lib/http/chainable.rb, line 99 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
Convert to a transparent TCP/IP tunnel
# File lib/http/chainable.rb, line 41 def connect(uri, options = {}) request :connect, uri, options end
# File lib/http/chainable.rb, line 127 def default_callbacks default_options.callbacks end
# File lib/http/chainable.rb, line 131 def default_callbacks=(callbacks) @default_options = default_options.dup do |opts| opts.callbacks = callbacks end end
# File lib/http/chainable.rb, line 117 def default_headers default_options.headers end
# File lib/http/chainable.rb, line 121 def default_headers=(headers) @default_options = default_options.dup do |opts| opts.headers = headers end end
# File lib/http/chainable.rb, line 109 def default_options @default_options ||= HTTP::Options.new end
# File lib/http/chainable.rb, line 113 def default_options=(opts) @default_options = HTTP::Options.new(opts) end
Delete a resource
# File lib/http/chainable.rb, line 26 def delete(uri, options = {}) request :delete, uri, options end
Make client follow redirects. @param opts (see Redirector#initialize) @return [HTTP::Client]
# File lib/http/chainable.rb, line 79 def follow(opts = true) branch default_options.with_follow opts end
Get a resource
# File lib/http/chainable.rb, line 11 def get(uri, options = {}) request :get, uri, options end
Request a get sans response body
# File lib/http/chainable.rb, line 6 def head(uri, options = {}) request :head, uri, options end
Return the methods supported on the given URI
# File lib/http/chainable.rb, line 36 def options(uri, options = {}) request :options, uri, options end
Apply partial modifications to a resource
# File lib/http/chainable.rb, line 46 def patch(uri, options = {}) request :patch, uri, options end
Post to a resource
# File lib/http/chainable.rb, line 16 def post(uri, options = {}) request :post, uri, options end
Put to a resource
# File lib/http/chainable.rb, line 21 def put(uri, options = {}) request :put, uri, options end
Make an HTTP request with the given verb
# File lib/http/chainable.rb, line 51 def request(verb, uri, options = {}) branch(options).request verb, uri end
Alias for with_response(:object)
# File lib/http/chainable.rb, line 72 def stream with_response(:object) end
Echo the request back to the client
# File lib/http/chainable.rb, line 31 def trace(uri, options = {}) request :trace, uri, options end
Make a request through an HTTP proxy
# File lib/http/chainable.rb, line 56 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
Make a request with the given headers
# File lib/http/chainable.rb, line 88 def with_headers(headers) branch default_options.with_headers(headers) end
Generated with the Darkfish Rdoc Generator 2.