summaryrefslogtreecommitdiff
path: root/lib/TUWF/Request.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-01-22 20:01:22 +0100
committerYorhel <git@yorhel.nl>2011-01-22 20:01:22 +0100
commit9f80f7f845c90ed4340eed26348e1dbdc397b440 (patch)
tree52711c9e9e9d4a604334d7642a734d37700ebe40 /lib/TUWF/Request.pm
parent687611310277257247767cdc68a4def1f9086ed4 (diff)
TUWF::Request: Provide defaults for missing data
Also gets rid of Perl warnings when run as a shell script. (Which in turn is useful when debugging)
Diffstat (limited to 'lib/TUWF/Request.pm')
-rw-r--r--lib/TUWF/Request.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/TUWF/Request.pm b/lib/TUWF/Request.pm
index a5975c7..47cfca7 100644
--- a/lib/TUWF/Request.pm
+++ b/lib/TUWF/Request.pm
@@ -243,30 +243,30 @@ sub reqHeader {
# returns the path part of the current URI, excluding the leading slash
sub reqPath {
- (my $u = $ENV{REQUEST_URI}) =~ s{^/+}{};
+ (my $u = ($ENV{REQUEST_URI}||'')) =~ s{^/+}{};
return decode_utf8 $u;
}
# returns base URI, excluding trailing slash
sub reqBaseURI {
- return decode_utf8 ($ENV{HTTPS} ? 'https://' : 'http://').$ENV{HTTP_HOST};
+ return decode_utf8($ENV{HTTPS} ? 'https://' : 'http://').shift->reqHost();
}
sub reqURI {
my $s = shift;
- return $s->reqBaseURI().decode_utf8($ENV{REQUEST_URI}.($ENV{QUERY_STRING} ? '?'.$ENV{QUERY_STRING} : ''));
+ return $s->reqBaseURI().'/'.$s->reqPath().decode_utf8($ENV{QUERY_STRING} ? '?'.$ENV{QUERY_STRING} : '');
}
sub reqHost {
- return decode_utf8 $ENV{HTTP_HOST};
+ return decode_utf8 $ENV{HTTP_HOST}||'localhost';
}
sub reqIP {
- return decode_utf8 $ENV{REMOTE_ADDR};
+ return decode_utf8 $ENV{REMOTE_ADDR}||'0.0.0.0';
}