Parent

Files

Anemone::HTTP

Constants

REDIRECT_LIMIT

Maximum number of redirects to follow on each get_response

Attributes

Public Class Methods

new(opts = {}) click to toggle source
# File lib/anemone/http.rb, line 13
def initialize(opts = {})
  @connections = {}
  @opts = opts
  @cookie_store = CookieStore.new(@opts[:cookies])
end

Public Instance Methods

accept_cookies?() click to toggle source

Does this HTTP client accept cookies from the server?

# File lib/anemone/http.rb, line 73
def accept_cookies?
  @opts[:accept_cookies]
end
fetch_page(url, referer = nil, depth = nil) click to toggle source

Fetch a single Page from the response of an HTTP request to url. Just gets the final destination page.

# File lib/anemone/http.rb, line 23
def fetch_page(url, referer = nil, depth = nil)
  fetch_pages(url, referer, depth).last
end
fetch_pages(url, referer = nil, depth = nil) click to toggle source

Create new Pages from the response of an HTTP request to url, including redirects

# File lib/anemone/http.rb, line 31
def fetch_pages(url, referer = nil, depth = nil)
  begin
    url = URI(url) unless url.is_a?(URI)
    pages = []
    get(url, referer) do |response, code, location, redirect_to, response_time|
      pages << Page.new(location, :body => response.body.dup,
                                  :code => code,
                                  :headers => response.to_hash,
                                  :referer => referer,
                                  :depth => depth,
                                  :redirect_to => redirect_to,
                                  :response_time => response_time)
    end

    return pages
  rescue Exception => e
    if verbose?
      puts e.inspect
      puts e.backtrace
    end
    return [Page.new(url, :error => e)]
  end
end
proxy_host() click to toggle source

The proxy address string

# File lib/anemone/http.rb, line 80
def proxy_host
  @opts[:proxy_host]
end
proxy_port() click to toggle source

The proxy port

# File lib/anemone/http.rb, line 87
def proxy_port
  @opts[:proxy_port]
end
read_timeout() click to toggle source

HTTP read timeout in seconds

# File lib/anemone/http.rb, line 94
def read_timeout
  @opts[:read_timeout]
end
redirect_limit() click to toggle source

The maximum number of redirects to follow

# File lib/anemone/http.rb, line 58
def redirect_limit
  @opts[:redirect_limit] || REDIRECT_LIMIT
end
user_agent() click to toggle source

The user-agent string which will be sent with each request, or nil if no such option is set

# File lib/anemone/http.rb, line 66
def user_agent
  @opts[:user_agent]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.