/[Sack]/trunk/lib/Sack/Server/HTTP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Server/HTTP.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 210 - (show annotations)
Sat Nov 21 15:55:24 2009 UTC (14 years, 6 months ago) by dpavlin
File size: 811 byte(s)
simple http listener which dumps $info

1 package Sack::Server::HTTP;
2
3 use warnings;
4 use strict;
5
6 my $debug = 1;
7
8 use Data::Dump qw(dump);
9
10 sub static {}
11
12 sub request {
13 my ( $client, $callback ) = @_;
14
15 my $request = <$client>;
16
17 warn "WEB << $request\n" if $debug;
18
19 if ($request =~ m{^GET (/.*) HTTP/1.[01]}) {
20 my $method = $1;
21 my $param;
22 if ( $method =~ s{\?(.+)}{} ) {
23 foreach my $p ( split(/[&;]/, $1) ) {
24 my ($n,$v) = split(/=/, $p, 2);
25 $param->{$n} = $v;
26 }
27 warn "WEB << param: ",dump( $param ) if $debug;
28 }
29 if ( my $path = static( $client,$1 ) ) {
30 warn "WEB >> $path" if $debug;
31 } elsif ( $callback->( $client, $method, $param ) ) {
32 warn "WEB callback $path";
33 } else {
34 print $client "HTTP/1.0 500 No method\r\n";
35 }
36 close $client;
37 } else {
38 print $client "HTTP/1.0 501 Not implemented\r\n";
39 }
40 }
41
42 1;

  ViewVC Help
Powered by ViewVC 1.1.26