develooper Front page | perl.libwww | Postings from December 2003

Adding HTTP::Parser module to LWP

From:
David Robins
Date:
December 14, 2003 12:05
Subject:
Adding HTTP::Parser module to LWP
Message ID:
200312141357.17763.dbrobins@davidrobins.net
I have a stateful HTTP parser module that I've mentioned on the module-authors 
list and it was suggested that it be incorporated into LWP rather than 
directly added to CPAN.

I'm aware of a couple of HTTP request parsers (e.g. in 
POE::Component::Server::HTTP, HTTP::Daemon, and probably in SOAP::Lite too) 
but not a standalone one.

The module's add() method takes data and returns a 'hint' as to what it wants 
next (dies on error):
0 - done, call request() to get an HTTP::Request object
>0 - want this many bytes (e.g. Content-Length or chunked encoding)
-1 - need more data, not sure how much
-2 - need (at least) a full line of data

Of course, the hints can be completely ignored and data can just be passed in 
as received.

The module itself is viewable (temporarily) at 
http://davidrobins.net/code/misc/HTTP-Parser.pm.

I wrote it as part of an RVP (MS Instant Messenger) client, using the Event 
module for the event loop.

-- 
Dave
Isa. 40:31




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About