lib/www/mechanize/chain/header_resolver.rb in mechanize-0.9.2 vs lib/www/mechanize/chain/header_resolver.rb in mechanize-0.9.3
- old
+ new
@@ -1,15 +1,16 @@
module WWW
class Mechanize
class Chain
class HeaderResolver
include WWW::Handler
- def initialize(keep_alive, keep_alive_time, cookie_jar, user_agent)
+ def initialize(keep_alive, keep_alive_time, cookie_jar, user_agent, headers)
@keep_alive = keep_alive
@keep_alive_time = keep_alive_time
@cookie_jar = cookie_jar
@user_agent = user_agent
+ @headers = headers
end
def handle(ctx, params)
uri = params[:uri]
referer = params[:referer]
@@ -38,9 +39,13 @@
request['Referer'] = referer.uri.to_s
end
# Add User-Agent header to request
request['User-Agent'] = @user_agent if @user_agent
+
+ @headers.each do |k,v|
+ request[k] = v
+ end if request
super
end
end
end
end