Skip Menu |

This queue is for tickets about the WebService-Validator-HTML-W3C CPAN distribution.

Report information
The Basics
Id: 23944
Status: resolved
Priority: 0/
Queue: WebService-Validator-HTML-W3C

People
Owner: struan [...] cpan.org
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.14
Fixed in: (no value)



Subject: [WISH] pass a custom user agent
I would like to use my own caching LWP::UserAgent subclass. I am currently doing this successfully this with WebService::Validator::CSS::W3C by passing my own instantiated $ua. It would be handy if WebService::Validator::HTML::W3C had a similar feature. -- Chris
Subject: [PATCH] [WISH] pass a custom user agent
On Thu Dec 14 16:56:08 2006, CDOLAN wrote: Show quoted text
> I would like to use my own caching LWP::UserAgent subclass. I am > currently doing this successfully this with > WebService::Validator::CSS::W3C by passing my own instantiated $ua. It > would be handy if WebService::Validator::HTML::W3C had a similar feature. > > -- Chris
Attached is a simple, non-intrusive patch to accomplish this. Thanks, Chris
--- 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 );
From: STRUAN [...] cpan.org
On Mon Dec 18 14:29:17 2006, CDOLAN wrote: Show quoted text
> On Thu Dec 14 16:56:08 2006, CDOLAN wrote: > > Attached is a simple, non-intrusive patch to accomplish this.
Cool, This is now applied and will be on CPAN in version 0.16 shortly Thanks Struan