Changeset 534

Show
Ignore:
Timestamp:
06/18/07 12:41:39 (1 year ago)
Author:
stephenson
Message:

Initial attempt to put the user agent string into the individual browser modules (IE.pm and FF.pm).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/stephenson-browser_headers/lib/HoneyClient/Agent/Driver/Browser.pm

    r526 r534  
    965965    my $ua = LWP::UserAgent->new( 
    966966        timeout           => $timeout,            # Fixed timeout. 
    967         #max_redirect      => 0,                   # Ignore redirects. 
     967        #max_redirect      => 0,                   # Ignore redirects. Do we want to do that? 
    968968        protocols_allowed => [ 'http', 'https' ], # Allow only web protocols. 
     969        # This actually puts a "range = " header in the request, might want to get rid of that... 
    969970        max_size          => 1*1024*1024,         # Don't get larger than 1MB for testing 
    970971    ); 
     
    973974    # a little better. 
    974975    # TODO: Set the default headers, to mimic a regular browser (if need be). 
    975     # I'm thinking this could be set by IE/FF and passed via $args{'default_headers'} 
     976    # I'm thinking this could be set by IE/FF and/or passed via $args{'default_headers'} 
    976977    # as a HTTP::Headers object. 
    977     $ua->default_header( 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5' ); 
    978  
    979     my $response = $ua->request( 
    980                         HTTP::Request->new( 
    981                             GET => $args{'url'}, 
    982                             HTTP::Headers->new( 
    983                                 # TODO: Add custom headers here? 
    984                                 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 
    985                             ), 
    986                         ) 
    987     ); 
    988  
     978    my $req = HTTP::Request->new(GET => $args{'url'}, $self->getHeaders()); 
     979    my $response = $ua->request($req); 
     980     
    989981    # Get the base url from the response 
    990982    my $base = $response->base; 
  • honeyclient/branches/exp/stephenson-browser_headers/lib/HoneyClient/Agent/Driver/Browser/FF.pm

    r411 r534  
    241241####################################################################### 
    242242 
     243#sub getHeaders { 
     244# 
     245#    # - This function returns the appropriate headers for this 
     246#    #   particular browser type (application) 
     247#} 
     248 
     249sub getHeaders { 
     250    return HTTP::Headers->new( 
     251                Accept => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-shockwave-flash, */*', 
     252                Accept-Language => 'en-us', 
     253                UA-CPU => 'x86', 
     254                Accept-Encoding => 'gzip, deflate', 
     255                User-Agent => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)', 
     256                #Host: ldscatalog.com, 
     257                Proxy-Connection => 'Keep-Alive', 
     258       ); 
     259} 
     260 
     261####################################################################### 
     262 
    2432631; 
  • honeyclient/branches/exp/stephenson-browser_headers/lib/HoneyClient/Agent/Driver/Browser/IE.pm

    r411 r534  
    154154# TODO: Need unit testing. 
    155155use Win32::Job; 
     156 
     157# TODO: Need unit testing 
     158use HTTP::Headers; 
    156159 
    157160# TODO: clean this up. 
     
    262265####################################################################### 
    263266 
     267#sub getHeaders { 
     268# 
     269#    # - This function returns the appropriate headers for this 
     270#    #   particular browser type (application) 
     271#} 
     272 
     273sub getHeaders { 
     274    return HTTP::Headers->new( 
     275                Accept => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-shockwave-flash, */*', 
     276                Accept-Language => 'en-us', 
     277                UA-CPU => 'x86', 
     278                Accept-Encoding => 'gzip, deflate', 
     279                User-Agent => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)', 
     280                #Host: ldscatalog.com, 
     281                Proxy-Connection => 'Keep-Alive', 
     282       ); 
     283} 
     284 
     285####################################################################### 
     286 
    2642871; 
    265