- my $r = shift;
- print $r->{cgi}->header(-type => $r->{content_type},
- -content_length => length $r->{output},
- );
- print $r->{output};
+ my $r = shift;
+ my %processed = map { "-".$_,$r->{extra_headers}{$_} }
+ keys %{$r->{extra_headers}};
+ print $r->{cgi}->header(
+ -type => $r->{content_type},
+ -charset => $r->{document_encoding},
+ -content_length => do { use bytes; length $r->{output} },
+ %processed
+ ? %processed
+ : {}
+ );
+ print $r->{output};