Changeset 1887

Show
Ignore:
Timestamp:
07/20/06 00:40:14
Author:
bricas
Message:

added option to override the user agent

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/Changes

    r1885 r1887  
    22 
    330.06_02 Mon Jul 10 2006 
     4        - added option to override the useragent from new() 
    45        - fix undef warning 
    56        - turn utf8 flag off for queries 
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/lib/WWW/OpenSearch.pm

    r1886 r1887  
    77 
    88use Carp; 
    9 use LWP::UserAgent; 
    109use WWW::OpenSearch::Response; 
    1110use WWW::OpenSearch::Description; 
     
    4847=head1 CONSTRUCTOR 
    4948 
    50 =head2 new( $url
     49=head2 new( $url [, $useragent]
    5150 
    5251Constructs a new instance of WWW::OpenSearch using the given 
    5352URL as the location of the engine's OpenSearch Description 
    54 document (retrievable via the description_url accessor). 
     53document (retrievable via the description_url accessor). Pass any 
     54LWP::UserAgent compatible object if you wish to override the default 
     55agent. 
    5556 
    5657=head1 METHODS 
     
    114115 
    115116sub new { 
    116     my( $class, $url ) = @_; 
     117    my( $class, $url, $agent ) = @_; 
    117118     
    118119    croak( "No OpenSearch Description url provided" ) unless $url; 
     
    120121    my $self = $class->SUPER::new; 
    121122 
     123    unless( $agent ) { 
     124        require LWP::UserAgent; 
     125        $agent = LWP::UserAgent->new( agent => join( '/', ref $self, $VERSION ) ); 
     126    } 
     127 
    122128    $self->description_url( $url ); 
    123     $self->agent( LWP::UserAgent->new( agent => join( '/', ref $self, $VERSION ) ) ); 
     129    $self->agent( $agent ); 
    124130 
    125131    $self->fetch_description;