diff --git a/Rest.Net/HttpListenerResponseExtensions.cs b/Rest.Net/HttpListenerResponseExtensions.cs
index 8e376ef..a11fa94 100644
--- a/Rest.Net/HttpListenerResponseExtensions.cs
+++ b/Rest.Net/HttpListenerResponseExtensions.cs
@@ -16,6 +16,18 @@ namespace MontoyaTech.Rest.Net
///
public static class HttpListenerResponseExtensions
{
+ ///
+ /// Sets the response to have no body.
+ ///
+ ///
+ ///
+ public static HttpListenerResponse WithNoBody(this HttpListenerResponse response)
+ {
+ response.ContentLength64 = 0;
+
+ return response;
+ }
+
///
/// Sets the response content type to text and writes the given text to it.
///
@@ -26,7 +38,10 @@ namespace MontoyaTech.Rest.Net
{
response.ContentType = "text/plain; charset=utf-8";
+ response.ContentLength64 = text.Length;
+
var bytes = Encoding.UTF8.GetBytes(text);
+
response.OutputStream.Write(bytes, 0, bytes.Length);
return response;
@@ -63,6 +78,9 @@ namespace MontoyaTech.Rest.Net
response.ContentType = "application/json; charset=utf-8";
var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(obj));
+
+ response.ContentLength64 = bytes.Length;
+
response.OutputStream.Write(bytes, 0, bytes.Length);
return response;
@@ -133,6 +151,7 @@ namespace MontoyaTech.Rest.Net
response.ContentType = mimeType;
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(filePath)}""");
+ response.ContentLength64 = content.Length;
response.SendChunked = true;
using (var responseStream = response.OutputStream)
@@ -218,6 +237,7 @@ namespace MontoyaTech.Rest.Net
response.ContentType = mimeType;
response.Headers.Add("Content-Deposition", $@"attachment; filename=""{Path.GetFileName(filePath)}""");
response.Headers.Add("Content-Encoding", "gzip");
+ response.ContentLength64 = content.Length;
response.SendChunked = true;
using (var responseStream = response.OutputStream)
@@ -237,6 +257,9 @@ namespace MontoyaTech.Rest.Net
response.ContentType = "text/html; charset=utf-8";
var bytes = Encoding.UTF8.GetBytes(html);
+
+ response.ContentLength64 = html.Length;
+
response.OutputStream.Write(bytes, 0, bytes.Length);
return response;
diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj
index 8a59b13..c8adbcd 100644
--- a/Rest.Net/Rest.Net.csproj
+++ b/Rest.Net/Rest.Net.csproj
@@ -17,7 +17,7 @@
MontoyaTech.Rest.Net
MontoyaTech.Rest.Net
True
- 1.3.6
+ 1.3.7
Logo_Symbol_Black_Outline.png
diff --git a/Rest.Net/Route.cs b/Rest.Net/Route.cs
index 304442a..7816a5b 100644
--- a/Rest.Net/Route.cs
+++ b/Rest.Net/Route.cs
@@ -28,7 +28,7 @@ namespace MontoyaTech.Rest.Net
private Func Target;
///
- /// Whether or not to close the response after the route is invoked.
+ /// Whether or not to close the response after the route is invoked, default is true.
///
public bool CloseResponse = true;
@@ -38,9 +38,8 @@ namespace MontoyaTech.Rest.Net
internal Route() { }
///
- /// Creates a new route with a given method, syntax, target and optional close response flag.
+ /// Creates a new route with a given method, syntax, target and optional close response flag which defaults to true.
///
- ///
///
///
///
@@ -63,7 +62,6 @@ namespace MontoyaTech.Rest.Net
///
/// Creates a new route with a given method, syntax, target and optional close response flag.
///
- ///
///
///
///