Skip to content

Commit

Permalink
Moved the host_header code above user_agent code.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Feb 1, 2010
1 parent 4398d5c commit b323f79
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/spidr/agent.rb
Expand Up @@ -19,6 +19,9 @@ class Agent
include Events
include Actions

# HTTP Host Header to use
attr_accessor :host_header

# User-Agent to use
attr_accessor :user_agent

Expand All @@ -28,9 +31,6 @@ class Agent
# Referer to use
attr_accessor :referer

# HTTP Host Header to use
attr_accessor :host_header

# Delay in between fetching pages
attr_accessor :delay

Expand Down Expand Up @@ -67,15 +67,15 @@ class Agent
# @option :proxy [String] :password
# The password to authenticate with.
#
# @option options [String] :host_header
# The HTTP Host header to use with each request.
#
# @option options [String] :user_agent (Spidr.user_agent)
# The User-Agent string to send with each requests.
#
# @option options [String] :referer
# The Referer URL to send with each request.
#
# @option options [String] :host_header
# The HTTP Host header to use with each request.
#
# @option options [Integer] :delay (0)
# The number of seconds to pause between each request.
#
Expand All @@ -93,9 +93,9 @@ class Agent
# The newly created agent.
#
def initialize(options={},&block)
@host_header = options[:host_header]
@user_agent = (options[:user_agent] || Spidr.user_agent)
@referer = options[:referer]
@host_header = options[:host_header]

@sessions = SessionCache.new(options[:proxy] || Spidr.proxy)
@cookies = CookieJar.new
Expand Down Expand Up @@ -620,9 +620,9 @@ def prepare_request(url,&block)
sleep(@delay) if @delay > 0

headers = {}
headers['Host'] = @host_header if @host_header
headers['User-Agent'] = @user_agent if @user_agent
headers['Referer'] = @referer if @referer
headers['Host'] = @host_header if @host_header

if (authorization = @authorized.for_url(url))
headers['Authorization'] = "Basic #{authorization}"
Expand Down

0 comments on commit b323f79

Please sign in to comment.