fix: "zip" Content-Type resulting in null Stream for Artifacts on Blob Storage (#2905)

This commit is contained in:
Tom Longhurst
2024-04-15 15:28:10 +01:00
committed by GitHub
parent 889bf25979
commit 4ca8f1cd2c
2 changed files with 30 additions and 2 deletions
+9 -2
View File
@@ -81,7 +81,6 @@ namespace Octokit.Internal
AcceptHeaders.RawContentMediaType,
"application/zip" ,
"application/x-gzip" ,
"zip" , // Not a standard MIME type but see issue #2898
"application/octet-stream"};
var content = responseMessage.Content;
@@ -169,10 +168,18 @@ namespace Octokit.Internal
static string GetContentMediaType(HttpContent httpContent)
{
if (httpContent.Headers != null && httpContent.Headers.ContentType != null)
if (httpContent.Headers?.ContentType != null)
{
return httpContent.Headers.ContentType.MediaType;
}
// Issue #2898 - Bad "zip" Content-Type coming from Blob Storage for artifacts
if (httpContent.Headers?.TryGetValues("Content-Type", out var contentTypeValues) == true
&& contentTypeValues.FirstOrDefault() == "zip")
{
return "application/zip";
}
return null;
}