LWP (was Re: Timeout Handling (Re: WWW::HTTP ) )

Martijn Koster (m.koster@nexor.co.uk)
Thu, 18 May 1995 10:55:30 +0100


In message <9505171330.aa27849@q2.ics.uci.edu>, Martijn Koster writes:

> I was lwp'ing again,

To expand a little (no, this is not a release):

Real work has been creeping up to me lately. However, I've been able
to spend some time on LWP again (sigh, what will I do when my wife
starts working regular hours? :). Anyway...

Long overdue I have added changed the code to use URI::URL,
and be grouped under LWP:

 http://web.nexor.co.uk/users/mak/libwww-perl/LWP.old/

Then I decided to start all over again. This is either called "rapid
prototyping" or "going around in circles", not sure yet :-) It's still
far from ready, but as it'll be a while before I'll get there, have a
browse:

 http://web.nexor.co.uk/users/mak/doc/libwww-perl5/lwp.tar.gz
 http://web.nexor.co.uk/users/mak/doc/libwww-perl5/lwp.tar
 http://web.nexor.co.uk/users/mak/doc/libwww-perl5/lwp/

=head1 Latest incarnation of libwww-perl5.

I have been feeling uneasy about the temporal aspect of the
LWP.old::Response class. As Gisle's suggestion of built-in support for
scalar, file, and subs should satisfy most uses and allow for
extendability, I have decided the temporal aspect should go, and be
moved to a Protocol class. As this is Perl5.001, I have replaced the
fileWrite style functions and replaced the with a closure. It seems to
work, I hope it's not just fluke :-)

After reading Booch, and now having classes coming out of my ears, I
have turned Request/Response into non temporal objects. They currently
don't inherit from a LWP::Message, but probably should do.

The MIME header has made a comeback, as an object which the Request
and Response use (hasA, not IsA). Note the method forwarding in the
light of recent pp discussions :) I've also expanded it to deal with
repeated fields, and "good practice" ordering for output. The name
MIMEheader might be slightly inappropriate, as there isn't much
MIME-ness; LWP::Header might be better.

I've stolen the loading mechanism from URI::URL.pm, and created a
corresponding LWP::Protocol class.  Subclasses know how to handle
protocol requests, and do the temporal bits. Implementation of
subclasses is a lot less messy now they don't have to pass
communication descriptors around.

I've taken onboard Andreas' worries about eval, and there is now only
one eval in the user agent, which you can configure off.

At last I've made a UserAgent class as suggested by Tim (?).

Finally I've used some Perl5 techniques learned from the URI::URL
stuff, such as split pod, shifts etc.  Note: in true prototyping style
the documentation is rather lacking, but that's waiting for more
weekends.  I'm sure the perl hackers on this list have no trouble
fugiring out what's what.

Self-tests are a bit tricky on this library, so I've decided to have
an external test suite which talks to one or more CGI scripts (using
the CGI:: stuff of course).

OOD wise I think this is reasoneably elegant. Feel free to point out
gaping holes in the design, or implement the rest of the classes :-)

=head1 TO DO

Receive comments on these changes.

Podding

MDA! I can really do with a safe file upload facility,
and now MD5.pm is here...

Lots of other things.

=cut

-- Martijn
__________
Internet: m.koster@nexor.co.uk
X-400: C=GB; A= ; P=Nexor; O=Nexor; S=koster; I=M
WWW: http://web.nexor.co.uk/mak/mak.html