|
@@ -13,10 +13,36 @@ 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>();
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 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.
|
|
|
|
+ /// </summary>
|
|
|
|
+ protected virtual bool IsAsyncHandler
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The action to write the response to the output stream
|
|
/// The action to write the response to the output stream
|
|
/// </summary>
|
|
/// </summary>
|
|
- public Action<Stream> WriteStream { get; set; }
|
|
|
|
|
|
+ public virtual Action<Stream> WriteStream
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ return s =>
|
|
|
|
+ {
|
|
|
|
+ WriteReponse(s);
|
|
|
|
+
|
|
|
|
+ if (!IsAsyncHandler)
|
|
|
|
+ {
|
|
|
|
+ s.Dispose();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The original RequestContext
|
|
/// The original RequestContext
|
|
@@ -81,15 +107,6 @@ namespace MediaBrowser.Common.Net.Handlers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public BaseHandler()
|
|
|
|
- {
|
|
|
|
- WriteStream = s =>
|
|
|
|
- {
|
|
|
|
- WriteReponse(s);
|
|
|
|
- s.Dispose();
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void WriteReponse(Stream stream)
|
|
private void WriteReponse(Stream stream)
|
|
{
|
|
{
|
|
if (CompressResponse)
|
|
if (CompressResponse)
|