Class | Mechanize::HTTP::Agent |
In: |
lib/mechanize/http/agent.rb
|
Parent: | Object |
An HTTP (and local disk access) user agent. This class is an implementation detail and is subject to change at any time.
conditional_requests | [RW] | Disables If-Modified-Since conditional requests (enabled by default) |
gzip_enabled | [RW] | Is gzip compression of requests enabled? |
request_headers | [RW] | A hash of request headers to be used for every request |
user_agent | [R] | The User-Agent header to send |
history | [RW] | history of requests made |
content_encoding_hooks | [R] | A list of hooks to call to handle the content-encoding of a request. |
post_connect_hooks | [R] | A list of hooks to call after retrieving a response. Hooks are called with the agent and the response returned. |
pre_connect_hooks | [R] | A list of hooks to call before making a request. Hooks are called with the agent and the request to be performed. |
follow_meta_refresh | [RW] | Follow HTML meta refresh and HTTP Refresh. If set to +:anywhere+ meta refresh tags outside of the head element will be followed. | ||||||
follow_meta_refresh_self | [RW] |
Follow an HTML meta refresh that has no "url=" in the content
attribute.
Defaults to false to prevent infinite refresh loops. |
||||||
redirect_ok | [RW] |
Controls how this agent deals with redirects. The following values are
allowed:
|
||||||
redirection_limit | [RW] | Maximum number of redirects to follow |
robots | [R] | When true, this agent will consult the site‘s robots.txt for each access. |
pass | [RW] | OpenSSL key password |
keep_alive | [RW] | Set to false to disable HTTP/1.1 keep-alive requests |
open_timeout | [RW] | Length of time to wait until a connection is opened in seconds |
read_timeout | [RW] | Length of time to attempt to read data from the server |
cookie_jar | [RW] | The cookies for this agent |
max_file_buffer | [RW] | Responses larger than this will be written to a Tempfile instead of stored in memory. Setting this to nil disables creation of Tempfiles. |
context | [RW] | The context parses responses into pages |
ignore_bad_chunking | [RW] | When set to true mechanize will ignore an EOF during chunked transfer encoding so long as at least one byte was received. Be careful when enabling this as it may cause data loss. |
scheme_handlers | [RW] | Handlers for various URI schemes |
Adds credentials user, pass for uri. If realm is set the credentials are used only for that realm. If realm is not set the credentials become the default for any realm on that URI.
domain and realm are exclusive as NTLM does not follow RFC 2617. If domain is given it is only used for NTLM authentication.
Retrieves uri and parses it into a page or other object according to PluggableParser. If the URI is an HTTP or HTTPS scheme URI the given HTTP method is used to retrieve it, along with the HTTP headers, request params and HTTP referer.
redirects tracks the number of redirects experienced when retrieving the page. If it is over the redirection_limit an error will be raised.
Invokes hooks added to post_connect_hooks after a response is returned and the response body is handled.
Yields the context, the uri for the request, the response and the response body.
Decodes a gzip-encoded body_io. If it cannot be decoded, inflate is tried followed by raising an error.
Decodes a deflate-encoded body_io. If it cannot be decoded, raw inflate is tried followed by raising an error.
Sets the client certificate to given X509 certificate. If a path is given the certificate will be loaded and set.
A callback for additional certificate verification. See OpenSSL::SSL::SSLContext#verify_callback
The callback can be used for debugging or to ignore errors by always returning true. Specifying nil uses the default method that was valid when the SSLContext was created
Creates a new output IO by reading input_io in read_size chunks. If the output is over the max_file_buffer size a Tempfile with name is created.
If a block is provided, each chunk of input_io is yielded for further processing.