| Class | Client |
| In: |
lib/http-access2.rb
|
| Parent: | Object |
DESCRIPTION
HTTPAccess2::Client -- Client to retrieve web resources via HTTP.
How to create your client.
1. Create simple client.
clnt = HTTPAccess2::Client.new
2. Accessing resources through HTTP proxy.
clnt = HTTPAccess2::Client.new("http://myproxy:8080")
3. Set User-Agent and From in HTTP request header.(nil means "No proxy")
clnt = HTTPAccess2::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)
| NO_PROXY_HOSTS | = | ['localhost'] |
| agent_name | [R] | |
| cookie_manager | [RW] | |
| from | [R] | |
| ssl_config | [R] | |
| test_loopback_response | [R] |
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.
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.