Merge pull request #314 from Bond-009/fix303

Fixes possible NullReferenceException
This commit is contained in:
Joshua M. Boniface 2018-12-29 15:25:10 -05:00 committed by GitHub
commit 77a15fe404

View File

@ -112,12 +112,15 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary>
private IHasHeaders GetHttpResult(IRequest requestContext, byte[] content, string contentType, bool addCachePrevention, IDictionary<string, string> responseHeaders = null)
{
string compressionType = null;
bool isHeadRequest = false;
if (requestContext != null) {
compressionType = GetCompressionType(requestContext, content, contentType);
isHeadRequest = string.Equals(requestContext.Verb, "head", StringComparison.OrdinalIgnoreCase);
}
IHasHeaders result;
var compressionType = requestContext == null ? null : GetCompressionType(requestContext, content, contentType);
var isHeadRequest = string.Equals(requestContext.Verb, "head", StringComparison.OrdinalIgnoreCase);
if (string.IsNullOrEmpty(compressionType))
{
var contentLength = content.Length;
@ -791,4 +794,4 @@ namespace Emby.Server.Implementations.HttpServer
{
byte[] Compress(byte[] content);
}
}
}