--- lib/WebService/Validator/HTML/W3C.pm.orig 2006-12-18 13:15:29.000000000 -0600
+++ lib/WebService/Validator/HTML/W3C.pm 2006-12-18 13:19:25.000000000 -0600
@@ -11,7 +11,7 @@
use WebService::Validator::HTML::W3C::Warning;
__PACKAGE__->mk_accessors(
- qw( http_timeout validator_uri proxy _http_method
+ qw( http_timeout validator_uri proxy ua _http_method
is_valid num_errors uri _content _output ) );
use vars qw( $VERSION $VALIDATOR_URI $HTTP_TIMEOUT );
@@ -72,6 +72,12 @@
The URI of the validator to use. By default this accesses the W3Cs validator at
http://validator.w3.org/check. If you have a local installation of the validator ( recommended if you wish to do a lot of testing ) or wish to use a validator at another location then you can use this option. Please note that you need to use the full path to the validator cgi.
+=item ua
+
+The user agent to use. By default, this is C<LWP::UserAgent->new()>.
+If this argument is provided, the C<http_timeout> and C<proxy>
+arguments are ignored.
+
=item http_timeout
How long (in seconds) to wait for the HTTP connection to timeout when
@@ -112,6 +118,7 @@
$self->http_timeout( $args{http_timeout} || $HTTP_TIMEOUT );
$self->validator_uri( $args{validator_uri} || $VALIDATOR_URI );
+ $self->ua( $args{ua} );
$self->_http_method( $args{detailed} ? 'GET' : 'HEAD' );
$self->_output( $args{output} || 'xml' );
$self->proxy( $args{proxy} || '' );
@@ -177,10 +184,13 @@
my $uri_orig = $uri;
- my $ua = LWP::UserAgent->new( agent => __PACKAGE__ . "/$VERSION",
+ my $ua = $self->ua;
+ if ( ! $ua ) {
+ $ua = LWP::UserAgent->new( agent => __PACKAGE__ . "/$VERSION",
timeout => $self->http_timeout );
- if ( $self->proxy ) { $ua->proxy( 'http', $self->proxy ); }
+ if ( $self->proxy ) { $ua->proxy( 'http', $self->proxy ); }
+ }
my $request = $self->_get_request( $uri );