diff options
| author | hatharry <hatharry@hotmail.com> | 2016-07-25 23:29:52 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-25 23:29:52 +1200 |
| commit | f21f9923de6291aaf985f32dbbbaddbb26d07fb1 (patch) | |
| tree | 1a313e9a1c6790a755926bcef221c5f680537eae /MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | |
| parent | 6332d0b9436c511a59e2abd67ea8c24ce3d82ace (diff) | |
| parent | 8328f39834f042e1808fd8506bbc7c48151703ab (diff) | |
Merge pull request #15 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 6cedaa6a9..c0a2a5eb3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -294,7 +294,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer return null; } - public object GetStaticFileResult(IRequest requestContext, + public Task<object> GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read) { @@ -310,7 +310,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer }); } - public object GetStaticFileResult(IRequest requestContext, + public Task<object> GetStaticFileResult(IRequest requestContext, StaticFileResultOptions options) { var path = options.Path; @@ -331,7 +331,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer options.ContentType = MimeTypes.GetMimeType(path); } - options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path); + if (!options.DateLastModified.HasValue) + { + options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path); + } + var cacheKey = path + options.DateLastModified.Value.Ticks; options.CacheKey = cacheKey.GetMD5(); @@ -351,7 +355,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer return _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, fileShare); } - public object GetStaticResult(IRequest requestContext, + public Task<object> GetStaticResult(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, @@ -372,7 +376,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer }); } - public object GetStaticResult(IRequest requestContext, StaticResultOptions options) + public async Task<object> GetStaticResult(IRequest requestContext, StaticResultOptions options) { var cacheKey = options.CacheKey; options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); @@ -398,7 +402,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer } var compress = ShouldCompressResponse(requestContext, contentType); - var hasOptions = GetStaticResult(requestContext, options, compress).Result; + var hasOptions = await GetStaticResult(requestContext, options, compress).ConfigureAwait(false); AddResponseHeaders(hasOptions, options.ResponseHeaders); return hasOptions; @@ -699,5 +703,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw error; } + + public object GetAsyncStreamWriter(Func<Stream, Task> streamWriter, IDictionary<string, string> responseHeaders = null) + { + return new AsyncStreamWriterFunc(streamWriter, responseHeaders); + } } }
\ No newline at end of file |
