<span class="gmail_quote"><br></span><br>Hi... <br><br>Here's a working Perl script that I want to be able to do in Ruby: <br><br>use WWW::Mechanize;<br>my $url = "<a href="http://host/tt?name=chris" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://host/tt?name=chris</a>";<br>my $mech = WWW::Mechanize->new();
<br><br>$mech->add_header( Referer => "<a href="http://chrismcmahonsblog.blogspot.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://chrismcmahonsblog.blogspot.com</a>" );<br>
$mech->add_header( Cookie => "messageid=170118; memberid=1007");
<br>$mech->get($url)<br><br>so the header values for Referer and Cookie are passed with the HTTP GET. <br><br>There seems to be an add_field method in mechanize.rb: <br><br>request.add_field('Referer', cur_page.uri.to_s)
<br><br>and rdoc (<a href="http://mechanize.rubyforge.org/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mechanize.rubyforge.org/</a>) indicates an add_field value for Net::HTTPHeader, but the example is funny, because the example says "add_header", not "add_field".
<br><br>In either case, none of the "add_*" statements in the script below work, each yields an "undefined method" error. <br><br>require 'mechanize'<br>mech = WWW::Mechanize.new<br>#request.add_header('Referer', "
<a href="http://chrismcmahonsblog.blogspot.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://chrismcmahonsblog.blogspot.com</a>" )<br>#mech.add_header('Referer', "<a href="http://chrismcmahonsblog.blogspot.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://chrismcmahonsblog.blogspot.com</a>
" )<br>#mech.add_field('Cookie', "messageid=170118; memberid=1007")<br>puts mech.get("<a href="http://host/tt?name=chris" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://host/tt?name=chris
</a>").inspect<br><br>can anyone tell me how to add Referer and Cookie headers to an HTTP GET request?
<br>