From 81fd82d491c58df3d4883625620754d851cbbb03 Mon Sep 17 00:00:00 2001 From: Jessica Schumaker Date: Tue, 9 Oct 2018 11:24:24 -0400 Subject: [PATCH] devops: don't null ref when ContentType is null --- Microsoft.Alm.Authentication/Src/Network.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Microsoft.Alm.Authentication/Src/Network.cs b/Microsoft.Alm.Authentication/Src/Network.cs index e439dfb6d..cd7fd2143 100644 --- a/Microsoft.Alm.Authentication/Src/Network.cs +++ b/Microsoft.Alm.Authentication/Src/Network.cs @@ -687,7 +687,7 @@ public async Task SetContent(HttpContent content) if (content is null) throw new ArgumentNullException(nameof(content)); - if (content.Headers.ContentType.MediaType != null + if (content.Headers.ContentType?.MediaType != null && (content.Headers.ContentType.MediaType.StartsWith("text/", StringComparison.OrdinalIgnoreCase) || content.Headers.ContentType.MediaType.EndsWith("/json", StringComparison.OrdinalIgnoreCase))) { @@ -755,7 +755,7 @@ public async Task SetContent(HttpContent content) lock (_syncpoint) { - _mediaType = content.Headers.ContentType.MediaType; + _mediaType = content.Headers.ContentType?.MediaType; _byteArray = asBytes; } }