Added more examples. WithText and WithJson now specify Utf16 to support rich content.

This commit is contained in:
2022-02-06 21:32:01 -08:00
parent ccad0dd66d
commit 41bbabf1cb
2 changed files with 15 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ namespace MontoyaTech.Rest.Net
/// <returns></returns>
public static HttpListenerResponse WithText(this HttpListenerResponse response, string text)
{
response.ContentType = "text/plain";
response.ContentType = "text/plain; charset=utf-16";
var bytes = Encoding.Unicode.GetBytes(text);
response.OutputStream.Write(bytes, 0, bytes.Length);
@@ -38,7 +38,7 @@ namespace MontoyaTech.Rest.Net
/// <returns></returns>
public static HttpListenerResponse WithJson(this HttpListenerResponse response, object obj)
{
response.ContentType = "application/json";
response.ContentType = "application/json; charset=utf-16";
var bytes = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(obj));
response.OutputStream.Write(bytes, 0, bytes.Length);