mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] HTTPServer.pm: Serve index.html if no filename is given.
This commit is contained in:
parent
2a58c7d207
commit
2e4bc07697
@ -1,3 +1,7 @@
|
|||||||
|
2006-04-27 Mauro Tortonesi <mauro@ferrara.linux.it>
|
||||||
|
|
||||||
|
* HTTPServer.pm: Serve index.html if no filename is given.
|
||||||
|
|
||||||
2006-01-24 Mauro Tortonesi <mauro@ferrara.linux.it>
|
2006-01-24 Mauro Tortonesi <mauro@ferrara.linux.it>
|
||||||
|
|
||||||
* HTTPServer.pm: Enhanced logging support.
|
* HTTPServer.pm: Enhanced logging support.
|
||||||
|
@ -20,19 +20,25 @@ sub run {
|
|||||||
|
|
||||||
while (my $con = $self->accept) {
|
while (my $con = $self->accept) {
|
||||||
while (my $req = $con->get_request) {
|
while (my $req = $con->get_request) {
|
||||||
print STDERR "Method: ", $req->method, "\n" if $log;
|
my $url_path = $req->url->path;
|
||||||
print STDERR "Path: ", $req->url->path, "\n" if $log;
|
if ($url_path =~ m{/$}) {
|
||||||
foreach my $key (keys %{HTTPServer::urls}) {
|
$url_path .= 'index.html';
|
||||||
print STDERR $key, '\n';
|
|
||||||
}
|
}
|
||||||
if (exists($urls->{$req->url->path})) {
|
if ($log) {
|
||||||
print STDERR "Serving requested URL: ", $req->url->path, "\n" if $log;
|
print STDERR "Method: ", $req->method, "\n";
|
||||||
|
print STDERR "Path: ", $url_path, "\n";
|
||||||
|
print STDERR "Available URLs: ", "\n";
|
||||||
|
foreach my $key (keys %$urls) {
|
||||||
|
print STDERR $key, "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exists($urls->{$url_path})) {
|
||||||
|
print STDERR "Serving requested URL: ", $url_path, "\n" if $log;
|
||||||
next unless ($req->method eq "HEAD" || $req->method eq "GET");
|
next unless ($req->method eq "HEAD" || $req->method eq "GET");
|
||||||
|
|
||||||
# create response
|
# create response
|
||||||
my $tmp = $urls->{$req->url->path};
|
my $tmp = $urls->{$url_path};
|
||||||
my $resp = HTTP::Response->new ($tmp->{code},
|
my $resp = HTTP::Response->new ($tmp->{code}, $tmp->{msg});
|
||||||
$tmp->{msg});
|
|
||||||
print STDERR "HTTP::Response: \n", $resp->as_string if $log;
|
print STDERR "HTTP::Response: \n", $resp->as_string if $log;
|
||||||
|
|
||||||
#if (is_dynamic_url) { # dynamic resource
|
#if (is_dynamic_url) { # dynamic resource
|
||||||
@ -63,7 +69,7 @@ sub run {
|
|||||||
$con->send_response($resp);
|
$con->send_response($resp);
|
||||||
print STDERR "HTTP::Response sent: \n", $resp->as_string if $log;
|
print STDERR "HTTP::Response sent: \n", $resp->as_string if $log;
|
||||||
} else {
|
} else {
|
||||||
print STDERR "Requested wrong URL: ", $req->url->path, "\n" if $log;
|
print STDERR "Requested wrong URL: ", $url_path, "\n" if $log;
|
||||||
$con->send_error($HTTP::Status::RC_FORBIDDEN);
|
$con->send_error($HTTP::Status::RC_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user