Browse Source

Made chunked encoding overridable

LukePulverenti Luke Pulverenti luke pulverenti 13 years ago
parent
commit
442b9c559f

+ 16 - 0
MediaBrowser.Common/Net/Handlers/BaseHandler.cs

@@ -13,6 +13,22 @@ namespace MediaBrowser.Common.Net.Handlers
         /// </summary>
         /// </summary>
         public IDictionary<string, string> Headers = new Dictionary<string, string>();
         public IDictionary<string, string> Headers = new Dictionary<string, string>();
 
 
+        public virtual bool UseChunkedEncoding
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        public virtual long? ContentLength
+        {
+            get
+            {
+                return null;
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// Returns true or false indicating if the handler writes to the stream asynchronously.
         /// Returns true or false indicating if the handler writes to the stream asynchronously.
         /// If so the subclass will be responsible for disposing the stream when complete.
         /// If so the subclass will be responsible for disposing the stream when complete.

+ 6 - 1
MediaBrowser.Common/Net/RequestContext.cs

@@ -58,7 +58,12 @@ namespace MediaBrowser.Common.Net
 
 
             if (statusCode == 200)
             if (statusCode == 200)
             {
             {
-                Response.SendChunked = true;
+                Response.SendChunked = handler.UseChunkedEncoding;
+
+                if (handler.ContentLength.HasValue)
+                {
+                    Response.ContentLength64 = handler.ContentLength.Value;
+                }
 
 
                 if (handler.CompressResponse)
                 if (handler.CompressResponse)
                 {
                 {