Class | Client
In: | lib/facets/more/httpaccess.rb
Parent: | Object

DESCRIPTION

      HTTPAccess::Client -- Client to retrieve web resources via HTTP.

How to create your client.

      1. Create simple client.
        clnt = HTTPAccess::Client.new

      2. Accessing resources through HTTP proxy.
        clnt = HTTPAccess::Client.new("http://myproxy:8080")

      3. Set User-Agent and From in HTTP request header.(nil means "No proxy")
        clnt = HTTPAccess::Client.new(nil, "MyAgent", "nahi@keynauts.com")

How to retrieve web resources.

      1. Get content of specified URL.
        puts clnt.get_content("http://www.ruby-lang.org/en/")

      2. Do HEAD request.
        res = clnt.head(uri)

      3. Do GET request with query.
        res = clnt.get(uri)

      4. Do POST request.
        res = clnt.post(uri)
        res = clnt.get|post|head(uri, proxy)

### Methods

connect_timeout connect_timeout= debug_dev debug_dev= default_redirect_uri_callback delete delete_async get get_async get_content head head_async new no_proxy no_proxy= options options_async post post_async post_content protocol_version protocol_version= proxy proxy= put put_async receive_timeout receive_timeout= redirect_uri_callback= request request_async reset reset_all save_cookie_store send_timeout send_timeout= set_basic_auth set_cookie_store socket_sync= trace trace_async

### Constants

NO_PROXY_HOSTS | = | ['localhost']

### Attributes

agent_name | [R] |
cookie_manager | [RW] |
from | [R] |
ssl_config | [R] |
test_loopback_response | [R] |

### Public Class methods

new(proxy = nil, agent_name = nil, from = nil)

SYNOPSIS

      Client.new(proxy = nil, agent_name = nil, from = nil)

ARGS

      proxy             A String of HTTP proxy URL. ex. "http://proxy:8080".
      agent_name        A String for "User-Agent" HTTP request header.
      from              A String for "From" HTTP request header.

DESCRIPTION

      Create an instance.
      SSLConfig cannot be re-initialized.  Create new client.

### Public Instance methods

connect_timeout()
connect_timeout=(connect_timeout)
debug_dev()
debug_dev=(dev)
default_redirect_uri_callback(res)
delete(uri, extheader = {}, &block)
delete_async(uri, extheader = {})
get(uri, query = nil, extheader = {}, &block)
get_async(uri, query = nil, extheader = {})
get_content(uri, query = nil, extheader = {}, &block)

SYNOPSIS

      Client#get_content(uri, query = nil, extheader = {}, &block = nil)

ARGS

      uri       an_URI or a_string of uri to connect.
      query     a_hash or an_array of query part.  e.g. { "a" => "b" }.
                Give an array to pass multiple value like
                [["a" => "b"], ["a" => "c"]].
      extheader
                a_hash of extra headers like { "SOAPAction" => "urn:foo" }.
      &block    Give a block to get chunked message-body of response like
                get_content(uri) { |chunked_body| ... }
                Size of each chunk may not be the same.

DESCRIPTION

      Get a_sring of message-body of response.

head(uri, query = nil, extheader = {})
head_async(uri, query = nil, extheader = {})

Async interface.

no_proxy()
no_proxy=(no_proxy)
options(uri, extheader = {}, &block)
options_async(uri, extheader = {})
post(uri, body = nil, extheader = {}, &block)
post_async(uri, body = nil, extheader = {})
post_content(uri, body = nil, extheader = {}, &block)
protocol_version()
protocol_version=(protocol_version)
proxy()
proxy=(proxy)
put(uri, body = nil, extheader = {}, &block)
put_async(uri, body = nil, extheader = {})
receive_timeout()
receive_timeout=(receive_timeout)
redirect_uri_callback=(redirect_uri_callback)
request(method, uri, query = nil, body = nil, extheader = {}, &block)
request_async(method, uri, query = nil, body = nil, extheader = {})
reset(uri)

Management interface.

reset_all()
save_cookie_store()
send_timeout()
send_timeout=(send_timeout)
set_basic_auth(uri, user_id, passwd)
set_cookie_store(filename)
socket_sync=(socket_sync)

if your ruby is older than 2005-09-06, do not set socket_sync = false to avoid an SSL socket blocking bug in openssl/buffering.rb.

trace(uri, query = nil, body = nil, extheader = {}, &block)
trace_async(uri, query = nil, body = nil, extheader = {})

[Validate]