Hah!
Pretty easy in Perl with Mechanize:

use warnings;
use strict;
use WWW::Mechanize;

my $url = "http://host/tt?name=chris";;

my $mech = WWW::Mechanize->new();

$mech->add_header( Referer => "http://chrismcmahonsblog.blogspot.com"; );
$mech->add_header( Cookie => "messageid=170118; memberid=1007");
$mech->get($url)

On 12/8/06, Chris McMahon <[EMAIL PROTECTED]> wrote:



Hi...

As usual, thanks for the tolerance of this OT stuff.

I posted to the soap4r list (the soap4r guy Hiroshi Nakamura also wrote
the best net/http), but I thought someone here might have an idea:

I have a little script

require 'net/http'
Net::HTTP.start('host') do |http|
response = http.get('/tt?name=chris')
end


The headers that come across (shown in WireShark form) are

Hypertext Transfer Protocol
    GET /tt?name=chris HTTP/1.1\r\n
        Request Method: GET
        Request URI: /tt?name=chris
        Request Version: HTTP/1.1
    Accept: */*\r\n
    Host: host\r\n
    \r\n

I would like to be able to emulate a useragent that produces these header
values:

Hypertext Transfer Protocol
    GET /tt?name=chris HTTP/1.1\r\n
        Request Method: GET
        Request URI: /tt?name=chris
        Request Version: HTTP/1.1
    Host: host\r\n
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)
Gecko/20061010 Firefox/2.0\r\n
    Accept: image/png,*/*;q=0.5\r\n
    Accept-Language: en-us,en;q=0.5\r\n
    Accept-Encoding: gzip,deflate\r\n
    Accept-Charset: ISO-8859-1,utf-8;q=0.7 ,*;q=0.7\r\n
    Keep-Alive: 300\r\n
    Connection: keep-alive\r\n
    Referer: 
http://chrismcmahonsblog.blogspot.com/\r\n<http://chrismcmahonsblog.blogspot.com/%5Cr%5Cn>
    Cookie: messageid=170118; memberid=1007\r\n
    Authorization: Basic YWRxyzabc25tbA==\r\n
    \r\n

of particular interest are
Referer: 
http://chrismcmahonsblog.blogspot.com/\r\n<http://chrismcmahonsblog.blogspot.com/%5Cr%5Cn>
Cookie: messageid=170118; memberid=1007\r\n

I've done this a bit with the SOAP protocols, but now I need to do with a
simple GET, and I'm not finding much for examples.  Any pointers would be
appreciated.


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to