develooper Front page | perl.libwww | Postings from November 2001

Re: Net::HTTP restructuring

Gisle Aas
November 16, 2001 19:54
Re: Net::HTTP restructuring
Message ID:
Steve Fink <> writes:

> Quoting Gisle Aas (
> > Steve Fink <> writes:
> > 
> > > In fact, I think I'll pester you directly for the next thing -- I was
> > > just wondering if you had any plans to change Net::HTTP (as you
> > > threaten in the documentation). If so, let me put in a feature request.
> > 
> > I think the interface is pretty good now and will basically stay that
> > way.
> Good, I don't want the interface to change. The _rbuf method is the
> only one that makes me nervous, but it's probably necessary as long as
> IO::Handles can't unget?

The "_" in front of these method names should be an indication that I
think this is a bit ugly and the part of the API that is most

I could probably make a nicer interface, for instance based on the
protocol code calling ->http_read() and ->http_unread().  I was a bit
afraid of getting too many levels of indirection when I wrote that

The current 'readline' code looks like this:

   for (${*$self}{'http_buf'}) {
      while (not enough in $buf)) {
          sysread($self, $_, 1024);
      return substr($_, 0, $pos, "");

with a cleaner interface it could look like this:

   $_ = "";
   while (not enough in $buf) {
       $self->http_read($_, 1024);
   my $line = substr($_, 0, $pos, "");
   $self->http_unread($_) if length;
   return $line;

I should probably meassure this.  Perhaps the cost is not as big as I
think and it would really be worthwhile to clean up that part of the

> > Does this sound like a plan?
> Sounds good to me!

Good.  I just did this change and then uploaded libwww-perl-5.61 to
CPAN.  The change also made the LWP::Protocol::https module much

But, the main reason to get 5.61 out is that there was a serious bug
in the handling of 'Host' header when going through a proxy:

There was lots of discussion about the handling of bad protocol
headers this week. No fix for that made it into this release.  This
has to wait until 5.62.

> > Can anybody suggest a better name than 'Net::HTTP::Methods'?
> Net::HTTP::Protocol? ::Process?

Hmmm.  I'm not sure I like those.  And I don't feel obliged to keep
'Net::HTTP::Methods' even though this is the name it has in the
released 5.61.  More suggestions are still welcomed.

How about calling it ::Mixin?  Actually we have some precedence for
that in LWP::MemberMixin, but no other CPAN module uses that word.
Any other precedence for naming from similar inheritance patterns?

Gisle Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About