fix: send charset=utf-8 for content-type header

This commit is contained in:
Oliver Booth 2023-08-11 16:42:12 +01:00
parent 7bd1c5a45a
commit cd0f38764d
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 6 additions and 4 deletions

View File

@ -29,18 +29,20 @@ public class RawArticle : PageModel
{ {
return NotFound(); return NotFound();
} }
Response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder();
builder.AppendLine("# " + post.Title); builder.AppendLine("# " + post.Title);
if (_blogService.TryGetAuthor(post, out Author? author)) if (_blogService.TryGetAuthor(post, out Author? author))
builder.AppendLine($"Author: {author.Name}"); builder.AppendLine($"Author: {author.Name}");
builder.AppendLine($"Published: {post.Published:R}"); builder.AppendLine($"Published: {post.Published:R}");
if (post.Updated.HasValue) if (post.Updated.HasValue)
builder.AppendLine($"Updated: {post.Updated:R}"); builder.AppendLine($"Updated: {post.Updated:R}");
builder.AppendLine(); builder.AppendLine();
builder.AppendLine(post.Body); builder.AppendLine(post.Body);
return Content(builder.ToString(), "text/plain"); return Content(builder.ToString());
} }
} }