Skip to content

Commit c1bdb8d

Browse files
committed
Computing Content-Length from bytes, not characters
1 parent 0fd9833 commit c1bdb8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

UnisaveWorker/OwinExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Json;
4+
using System.Text;
45
using System.Threading.Tasks;
56
using Microsoft.Owin;
67
using Owin;
@@ -73,13 +74,16 @@ public static async Task SendResponse(
7374
return;
7475
}
7576

77+
// string to bytes
78+
byte[] binaryBody = Encoding.UTF8.GetBytes(body);
79+
7680
// send response with body
7781
context.Response.Headers["Content-Length"]
78-
= body.Length.ToString();
82+
= binaryBody.Length.ToString();
7983

8084
try
8185
{
82-
await context.Response.WriteAsync(body);
86+
await context.Response.WriteAsync(binaryBody);
8387
}
8488
catch (IOException e)
8589
{

0 commit comments

Comments
 (0)