From 1fd9cb5e2afe076f9a3093cdcd5f328ec0d547d1 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 11 Oct 2017 17:59:35 +0900 Subject: [PATCH] Remove BOM + add content-type if there is an error --- BTCPayServer/Hosting/BTCpayMiddleware.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Hosting/BTCpayMiddleware.cs b/BTCPayServer/Hosting/BTCpayMiddleware.cs index 29c7c475c..5e3e566bd 100644 --- a/BTCPayServer/Hosting/BTCpayMiddleware.cs +++ b/BTCPayServer/Hosting/BTCpayMiddleware.cs @@ -92,8 +92,9 @@ namespace BTCPayServer.Hosting private static async Task HandleBitpayHttpException(HttpContext httpContext, BitpayHttpException ex) { httpContext.Response.StatusCode = ex.StatusCode; - using(var writer = new StreamWriter(httpContext.Response.Body, Encoding.UTF8, 1024, true)) + using(var writer = new StreamWriter(httpContext.Response.Body, new UTF8Encoding(false), 1024, true)) { + httpContext.Response.ContentType = "application/json"; var result = JsonConvert.SerializeObject(new BitpayErrorsModel(ex)); writer.Write(result); await writer.FlushAsync();