Skip Menu |

This queue is for tickets about the HTTP-Server-Simple-Static CPAN distribution.

Report information
The Basics
Id: 37701
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple-Static

People
Owner: Nobody in particular
Requestors: granjeau [...] tagc.univ-mrs.fr
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.08



Subject: Wish on the doc
Date: Tue, 15 Jul 2008 18:13:34 +0200
To: bug-HTTP-Server-Simple-Static [...] rt.cpan.org
From: Samuel GRANJEAUD - IR/ICIM <granjeau [...] tagc.univ-mrs.fr>
Hello ! To add the serve_static function, I feel that an example could be useful. To my opinion, because the simple server is used to implement CGI, it should look like (borrowed from HTTP::Server::Simple): sub handle_request { my $self = shift; my $cgi = shift; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; if (ref($handler) eq "CODE") { print "HTTP/1.0 200 OK\r\n"; $handler->($cgi); } elsif (!$self->serve_static( $cgi, $webroot )) { print "HTTP/1.0 404 Not found\r\n"; print $cgi->header, $cgi->start_html('Not found'), $cgi->h1('Not found'), $cgi->end_html; } } $webroot should also be defined somewhere. It should be nice to have a link to HTTP::Server::Simple in the See also section. Best regards. PS: do not forget to close patch once implemented.
This was fixed in version 0.08 Regards, Stephen Quinney On Tue Jul 15 12:13:58 2008, granjeau@tagc.univ-mrs.fr wrote: Show quoted text
> Hello ! > > To add the serve_static function, I feel that an example could be > useful. To my opinion, because the simple server is used to implement > CGI, it should look like (borrowed from HTTP::Server::Simple): > > sub handle_request { > my $self = shift; > my $cgi = shift; > > my $path = $cgi->path_info(); > my $handler = $dispatch{$path}; > > if (ref($handler) eq "CODE") { > print "HTTP/1.0 200 OK\r\n"; > $handler->($cgi); > } elsif (!$self->serve_static( $cgi, $webroot )) { > print "HTTP/1.0 404 Not found\r\n"; > print $cgi->header, > $cgi->start_html('Not found'), > $cgi->h1('Not found'), > $cgi->end_html; > } > } > > $webroot should also be defined somewhere. > > It should be nice to have a link to HTTP::Server::Simple in the See also > section. > > Best regards. > > PS: do not forget to close patch once implemented.