tags:

views:

29

answers:

1

I am writing a small glue tool for doing some testing and I would like to heavily leverage CPAN. My tool must act as an HTTP server to bridge posted data to other TCP connections and vice-versa.

I have started the tool using IO::Event, which has been working very well for me. I would like to integrate it with something like HTTP::Server::Simple to do the HTTP parsing for me rather than muck around with parsing the HTTP headers myself. A quick perusal of HTTP::Server::Simple didn't seem like it could just work, but perhaps I missed something.

Has anyone done something like this?

+1  A: 

After searching CPAN some more, I have found the module: HTTP::Parser. It appears to do exactly what I want.

Combining IO::Event and HTTP::Parser makes a very straightforward application for doing exactly what I want with a minimum amount of fuss.

Update: One thing that I should mention is that IO::Event by default will not handle binary data very well. It tries to use perl's buffered IO, which will try to deliver data according to the record separator. You can get around this by setting '$client->autoread(0);'. Once you do this, you have to use 'ie_read_ready()' events and do an explicit 'recv' call to get the data on the underlying filehandle. To send data, do a 'send' call on the underlying filehandle. This worked well for me.

efunneko