Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit f58ec17

Browse files
authored
Merge pull request #780 from jeschu1/nullref2
devops: don't null ref when ContentType is null
2 parents 906745d + 81fd82d commit f58ec17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Microsoft.Alm.Authentication/Src/Network.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ public async Task SetContent(HttpContent content)
687687
if (content is null)
688688
throw new ArgumentNullException(nameof(content));
689689

690-
if (content.Headers.ContentType.MediaType != null
690+
if (content.Headers.ContentType?.MediaType != null
691691
&& (content.Headers.ContentType.MediaType.StartsWith("text/", StringComparison.OrdinalIgnoreCase)
692692
|| content.Headers.ContentType.MediaType.EndsWith("/json", StringComparison.OrdinalIgnoreCase)))
693693
{
@@ -755,7 +755,7 @@ public async Task SetContent(HttpContent content)
755755

756756
lock (_syncpoint)
757757
{
758-
_mediaType = content.Headers.ContentType.MediaType;
758+
_mediaType = content.Headers.ContentType?.MediaType;
759759
_byteArray = asBytes;
760760
}
761761
}

0 commit comments

Comments
 (0)