Changeset 489

Show
Ignore:
Timestamp:
01/31/09 14:16:16 (3 years ago)
Author:
dom
Message:

Support configurable user-agent (also update copyright year and fix hard-coding the test port number in four places)

Location:
wiki-toolkit-plugin-ping/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit-plugin-ping/trunk/Changes

    r488 r489  
    110.02     
    22        Skip database test when SQLite is not available 
    3         (fixes cpantesters 2957644, 3047914, 3122378) 
     3         (fixes cpantesters 2957644, 3047914, 3122378) 
     4        Support configurable user-agent (#18) 
    45 
    560.01    5 December 2006 
  • wiki-toolkit-plugin-ping/trunk/lib/Wiki/Toolkit/Plugin/Ping.pm

    r360 r489  
    1111 
    1212@ISA = qw( Wiki::Toolkit::Plugin ); 
    13 $VERSION = '0.01'; 
     13$VERSION = '0.02'; 
    1414 
    1515 
     
    3737    } 
    3838    $self->{node_to_url} = $args{node_to_url}; 
     39    $self->{agent} = $args{agent} || "Wiki::Toolkit::Plugin::Ping $VERSION"; 
    3940     
    4041 
     
    9899        # Get a LWP instance 
    99100        my $ua = LWP::UserAgent->new; 
    100         $ua->agent("Wiki::Toolkit::Plugin::Ping $version");         
     101        $ua->agent($self->{agent}); 
    101102 
    102103        # Ping each service 
     
    141142            services => { 
    142143                    "geourl" => 'http://geourl.org/ping?p=$url' 
    143             } 
     144            }, 
     145            agent    => "My Wiki ping agent", 
    144146  ); 
    145147  $wiki->register_pugin( plugin => $ping ); 
     
    152154 
    153155You need to tell it how to turn a node into a URL (node_to_url), and what 
    154 services to ping (services). 
     156services to ping (services). You can optionally pass a custom user-agent 
     157string 
    155158 
    156159=head1 AUTHOR 
     
    160163=head1 COPYRIGHT 
    161164 
    162      Copyright (C) 2003-2004 I. P. Williams (ivorw_openguides [at] xemaps {dot} com). 
    163      Copyright (C) 2006 the Wiki::Toolkit team (http://www.wiki-toolkit.org/) 
    164      All Rights Reserved. 
     165Copyright (C) 2003-2004 I. P. Williams (ivorw_openguides [at] xemaps {dot} com). 
     166Copyright (C) 2006-2009 the Wiki::Toolkit team (http://www.wiki-toolkit.org/) 
     167All Rights Reserved. 
    165168 
    166169This module is free software; you can redistribute it and/or modify it 
  • wiki-toolkit-plugin-ping/trunk/t/02_call.t

    r488 r489  
    1414    plan skip_all => 'SQLite not availalbe'; 
    1515} else { 
    16     plan tests => 4; 
     16    plan tests => 5; 
    1717} 
    1818 
     
    2626my $wiki = Wiki::Toolkit->new( store=>$store ); 
    2727 
     28my $port = 112233; 
    2829 
    2930# Listen on a special port, so we can check a ping happened 
    3031my $sock = new IO::Socket::INET ( 
    31                     LocalPort => 112233, 
     32                    LocalPort => $port, 
    3233                    Proto => 'tcp', 
    3334                    Listen => 1, 
    3435); 
    3536unless($sock) { 
    36     die("Can't listen on port 112233 for test"); 
     37    die("Can't listen on port $port for test"); 
    3738} 
    3839 
     
    4243    node_to_url => "http://wiki.org/\$node", 
    4344    services => { 
    44         test => "http://localhost:112233/url=\$url" 
    45     } 
     45        test => "http://localhost:$port/url=\$url" 
     46    }, 
     47    agent => "Wiki::Toolkit::Plugin::Ping test suite", 
    4648); 
    4749ok( $plugin, "Plugin was created OK with the local URL" ); 
     
    7476my $allreq = join "\n", @req; 
    7577like( $req[0], qr/^GET \/url=http:\/\/wiki.org\/TestNode/, "Did right get" ); 
    76 like( $allreq, qr/^Host: localhost:112233/m, "Correct http/1.1 host" ); 
     78like( $allreq, qr/^Host: localhost:$port/m, "Correct http/1.1 host" ); 
     79like( $allreq, qr/^User-Agent: Wiki::Toolkit::Plugin::Ping test suite/m, "Correct user-agent" ); 
    7780 
    7881# Send them an OK