From b9b12ac92230cc6807623293b93cc22e5eb33684 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 3 Mar 2017 00:55:07 +0000 Subject: repobrowse: consistently set text charset For everything with relevant content, we'll try to set UTF-8 charset and reduce duplication when generating response headers. --- lib/PublicInbox/RepoGitRaw.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/RepoGitRaw.pm') diff --git a/lib/PublicInbox/RepoGitRaw.pm b/lib/PublicInbox/RepoGitRaw.pm index f02439ad..7d2c0d22 100644 --- a/lib/PublicInbox/RepoGitRaw.pm +++ b/lib/PublicInbox/RepoGitRaw.pm @@ -22,10 +22,10 @@ sub call_git_raw { if ($type eq 'blob') { $type = git_blob_mime_type($self, $req, $cat, \$buf, \$left); } elsif ($type eq 'commit' || $type eq 'tag') { - $type = 'text/plain'; + $type = 'text/plain; charset=UTF-8'; } elsif ($type eq 'tree') { $git->cat_file_finish($left); - return git_tree_raw($req, $git, $hex); + return git_tree_raw($self, $req, $git, $hex); } else { $type = 'application/octet-stream'; } @@ -61,7 +61,7 @@ sub git_tree_sed ($) { # This should follow the cgit DOM structure in case anybody depends on it, # not using
 here as we don't expect people to actually view it much
 sub git_tree_raw {
-	my ($req, $git, $hex) = @_;
+	my ($self, $req, $git, $hex) = @_;
 
 	my @ex = @{$req->{extra}};
 	my $rel = $req->{relcmd};
@@ -83,10 +83,10 @@ sub git_tree_raw {
 	$qsp->psgi_return($env, undef, sub {
 		my ($r) = @_;
 		if (!defined $r) {
-			[ 500, [ 'Content-Type', 'text/plain' ], [ $git->err ]];
+			$self->rt(500, 'plain', $git->err);
 		} else {
 			$env->{'qspawn.filter'} = git_tree_sed($req);
-			[ 200, [ 'Content-Type', 'text/html' ] ];
+			$self->rt(200, 'html');
 		}
 	});
 }
-- 
cgit v1.2.3-24-ge0c7