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> /// </summary>
private IHasHeaders GetHttpResult(IRequest requestContext, byte[] content, string contentType, bool addCachePrevention, IDictionary<string, string> responseHeaders = null) 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; IHasHeaders result;
var compressionType = requestContext == null ? null : GetCompressionType(requestContext, content, contentType);
var isHeadRequest = string.Equals(requestContext.Verb, "head", StringComparison.OrdinalIgnoreCase);
if (string.IsNullOrEmpty(compressionType)) if (string.IsNullOrEmpty(compressionType))
{ {
var contentLength = content.Length; var contentLength = content.Length;