0

Handle absent url header correctly

This commit is contained in:
eleksir
2021-04-24 22:57:41 +03:00
parent 29acad6d7d
commit 2a90ce5e57

View File

@@ -24,6 +24,11 @@ my $app = sub {
if ($env->{PATH_INFO} eq "/image_dl") { if ($env->{PATH_INFO} eq "/image_dl") {
my $str = $env->{HTTP_URL}; my $str = $env->{HTTP_URL};
unless (defined $str) {
$msg = "No url http header supplied.\n";
return [ '400', [ 'Content-Type' => $content, 'Content-Length' => length ($msg) ], [ $msg ], ];
}
unless ((substr ($str, 0, 7) eq 'http://') || (substr ($str, 0, 8) eq 'https://')) { unless ((substr ($str, 0, 7) eq 'http://') || (substr ($str, 0, 8) eq 'https://')) {
$msg = "Incorrect URL\n"; $msg = "Incorrect URL\n";
return [ '400', [ 'Content-Type' => $content, 'Content-Length' => length ($msg) ], [ $msg ], ]; return [ '400', [ 'Content-Type' => $content, 'Content-Length' => length ($msg) ], [ $msg ], ];