Simon Wistow <[EMAIL PROTECTED]> writes:

> On Fri, Sep 19, 2003 at 06:40:18AM -0700, Gisle Aas said:
> > There is no direct way to do it currently.  You might be able to just
> > make your own subclass of LWP::Protocol::http that does what you want.
> > You then need to register it as the HTTP handler module with:
> > 
> >   LWP::Protocol::implementor('http', 'MyHTTP');
> > 
> > given that you called your LWP::Protocol::http subclass MyHTTP.
> 
> After a discussion with David and a bit of hackery I've packaged up his 
> code as a standalone module and was considering releasing it to CPAN.

Good.

> Currently the interface looks something like this
> 
> 
>       use LWP::UserAgent;
>       use LWP::Protocol::http::Timed qw(autoinstall);

I would make it ':autoinstall' to make it more obvious that something
strange is happening here.

>       my $ua = new LWP::UserAgent;
>       my $response = $ua->get("http://thegestalt.org";);
>       printf  "%f\n", $response->header('X-Request-Connect-Time');

Since LWP itself hijacks the "Client-" header namespace you might
consider using that namespace as well.  Something like
'Client-Request-Connect-Time'.

> or, more explicitly 
> 
> 
>       use LWP::UserAgent;
>       use LWP::Protocol;
> 
>       LWP::Protocol::implementor('http', 'LWP::Protocol::http::Timed');
> 
>     my $ua = new LWP::UserAgent;
>     my $response = $ua->get("http://thegestalt.org";);
>     printf  "%f\n", $response->header('X-Request-Connect-Time');
> 
> 
> 
> does that seem sane?
> 
> I'm not entirely in love with the name either so suggestions welcome.

You could just shorten it to something 'LWP::TimedHTTP'.  I don't
think there is a need to be in the LWP::Protocol namespace.  One risk
of using the LWP namespace is that you might end up in conflict with a
name LWP wants to use later.  One possiblity here is to start using a
namespace like LWPx (similar to DBIx) for such independent addons.

Regards,
Gisle

Reply via email to