Category Archives: Perl

Simple HTTP proxy with Perl

Today i had to demonstrate my version of a HTTP proxy and hand in the code. There are already various programs that do this, but here is my version: httpproxy.txt

Posted in Perl | 1 Comment

Parsing http headers

Today i updated my HTTP proxy a little. RFC 2616 describes Message Headers as following: message-header = field-name “:” [ field-value ] field-name = token field-value = *( field-content | LWS ) field-content = <the OCTETs making up the field-value … Continue reading

Posted in Perl | Leave a comment

Reading http chunked body

Here is my implementation of Chunked Transfer Coding. I find it quite elegant compared to other snippets i’ve seen. ################################################### # {{{ read body chunked ################################################### sub getbodychunked { my $sh = shift; # the socket handle should be passed … Continue reading

Posted in Perl | Leave a comment

Handling options

Last couple of days i’ve been writing a little script in Perl. One of the requirements is the following: it accepts (eventual) parameters to indicate the port it should use, where it should write log messages, how verbose the logging … Continue reading

Posted in Perl | Leave a comment

Passing a filehandle as parameter

To keep things maintainable we split our program in modules, classes, functions… In perlsub from the execellent perl documentation you can lookup the syntax of how to use functions. Offcourse, you have to digg pretty deep to find out how … Continue reading

Posted in Perl | Leave a comment