Class: Mechanize::Chain::CustomHeaders

Inherits:
Object
  • Object
show all
Includes:
Handler
Defined in:
lib/mechanize/chain/custom_headers.rb

Instance Attribute Summary

Attributes included from Handler

#chain

Instance Method Summary collapse

Instance Method Details

#handle(ctx, params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mechanize/chain/custom_headers.rb', line 6

def handle(ctx, params)
  request = params[:request]
  params[:headers].each do |k,v|
    case k
    when :etag then request["ETag"] = v
    when :if_modified_since then request["If-Modified-Since"] = v
    else
      raise ArgumentError.new("unknown header symbol #{k}") if k.is_a? Symbol
      request[k] = v
    end
  end
  super
end