summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-07-29 12:47:37 +0200
committerYorhel <git@yorhel.nl>2020-07-29 12:47:39 +0200
commitf68842f87baf3023836518712815c4f451b0db41 (patch)
tree9203c9a4d05f8eda6522e10be3b4ee8ae5de5e2f
parentdad3d15575842cce9d2c50904555b0ec907cafe6 (diff)
TUWF::Response: Properly UTF-8 encode headersHEADmaster
Non-ASCII headers aren't exactly common, but they can happen and should be encoded properly.
-rw-r--r--lib/TUWF/Response.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/TUWF/Response.pm b/lib/TUWF/Response.pm
index 628eb4d..d2b7150 100644
--- a/lib/TUWF/Response.pm
+++ b/lib/TUWF/Response.pm
@@ -5,6 +5,7 @@ package TUWF::Response;
use strict;
use warnings;
use Exporter 'import';
+use Encode 'encode_utf8';
use POSIX 'strftime';
use Carp 'croak';
@@ -244,9 +245,9 @@ sub resFinish {
} else {
printf "Status: %d\r\n", $i->{status};
}
- printf "%s: %s\r\n", $i->{headers}[$_*2], $i->{headers}[$_*2+1]
+ printf "%s: %s\r\n", encode_utf8($i->{headers}[$_*2]), encode_utf8($i->{headers}[$_*2+1])
for (0..$#{$i->{headers}}/2);
- printf "Set-Cookie: %s\r\n", $i->{cookies}{$_} for (keys %{$i->{cookies}});
+ printf "Set-Cookie: %s\r\n", encode_utf8 $i->{cookies}{$_} for (keys %{$i->{cookies}});
print "\r\n";
print $i->{content} if $self->reqMethod() ne 'HEAD';