diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 16:38:31 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 16:38:31 -0400 |
| commit | 937d27ae9d6aa571ab9327f138bfba1b84c158db (patch) | |
| tree | 94be178039621ea6d6235967414b0849912af4ed /MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs | |
| parent | 64887fa74347260d44a8cb5cc7058cd22b08c1c5 (diff) | |
One async call leads to another, and another, all the way up the call stack...
Diffstat (limited to 'MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs')
| -rw-r--r-- | MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs index 5656f9273..d8971dd97 100644 --- a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs +++ b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs @@ -77,27 +77,22 @@ namespace MediaBrowser.Common.Net.Handlers }
}
- public override bool CompressResponse
+ public override bool ShouldCompressResponse(string contentType)
{
- get
+ // Can't compress these
+ if (IsRangeRequest)
{
- // Can't compress these
- if (IsRangeRequest)
- {
- return false;
- }
-
- string contentType = ContentType;
-
- // Don't compress media
- if (contentType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase) || contentType.StartsWith("video/", StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
+ return false;
+ }
- // It will take some work to support compression within this handler
+ // Don't compress media
+ if (contentType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase) || contentType.StartsWith("video/", StringComparison.OrdinalIgnoreCase))
+ {
return false;
}
+
+ // It will take some work to support compression within this handler
+ return false;
}
protected override long? GetTotalContentLength()
@@ -105,31 +100,32 @@ namespace MediaBrowser.Common.Net.Handlers return SourceStream.Length;
}
- protected override DateTime? GetLastDateModified()
+ protected override Task<DateTime?> GetLastDateModified()
{
- EnsureSourceStream();
-
- if (SourceStream == null)
+ return Task.Run<DateTime?>(() =>
{
- return null;
- }
+ EnsureSourceStream();
+
+ if (SourceStream == null)
+ {
+ return null;
+ }
- return File.GetLastWriteTime(Path);
+ return File.GetLastWriteTime(Path);
+ });
}
- public override string ContentType
+ public override Task<string> GetContentType()
{
- get
+ return Task.Run(() =>
{
return MimeTypes.GetMimeType(Path);
- }
+ });
}
- protected override void PrepareResponse()
+ protected override Task PrepareResponse()
{
- base.PrepareResponse();
-
- EnsureSourceStream();
+ return Task.Run(() => { EnsureSourceStream(); });
}
protected async override Task WriteResponseToOutputStream(Stream stream)
|
