From 95dbed04e5cda01be5ee6668d5887e82fb183599 Mon Sep 17 00:00:00 2001 From: Andreas Bachlechner <62039342+bachandi@users.noreply.github.com> Date: Tue, 5 Jul 2022 22:03:54 +0200 Subject: [PATCH] Fix warning for undefined mimetype on some http requests. --- lib/HTTPServer.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/HTTPServer.pm b/lib/HTTPServer.pm index b02a8f7..59774cb 100644 --- a/lib/HTTPServer.pm +++ b/lib/HTTPServer.pm @@ -167,14 +167,16 @@ sub http_header { print "Server: Monitorix HTTP Server\r\n"; print "Connection: close\r\n"; - if($mimetype =~ m/(html|cgi)/) { - print "Content-Type: text/html; charset=UTF-8\r\n"; - } elsif($mimetype eq "css") { - print "Content-Type: text/css; charset=UTF-8\r\n"; - } elsif($mimetype eq "svg") { - print "Content-Type: image/svg+xml; charset=UTF-8\r\n"; - } else { - print "Content-Type: image/$mimetype;\r\n"; + if (defined($mimetype)) { + if($mimetype =~ m/(html|cgi)/) { + print "Content-Type: text/html; charset=UTF-8\r\n"; + } elsif($mimetype eq "css") { + print "Content-Type: text/css; charset=UTF-8\r\n"; + } elsif($mimetype eq "svg") { + print "Content-Type: image/svg+xml; charset=UTF-8\r\n"; + } else { + print "Content-Type: image/$mimetype;\r\n"; + } } print "\r\n";