mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 12:42:32 +00:00
Fixes for Downloading ReleaseAsset zip File #854
This commit addressed the `BuildResponse` wasn't handling response `content-type` `application/octet-stream` for binary items.
This commit is contained in:
@@ -70,16 +70,22 @@ namespace Octokit.Internal
|
||||
|
||||
object responseBody = null;
|
||||
string contentType = null;
|
||||
|
||||
// We added support for downloading images,zip-files and application/octet-stream.
|
||||
// Let's constrain this appropriately.
|
||||
var binaryContentTypes = new[] {"application/zip"
|
||||
,"application/x-gzip",
|
||||
"application/octet-stream"};
|
||||
|
||||
using (var content = responseMessage.Content)
|
||||
{
|
||||
if (content != null)
|
||||
{
|
||||
contentType = GetContentMediaType(responseMessage.Content);
|
||||
|
||||
// We added support for downloading images and zip-files. Let's constrain this appropriately.
|
||||
if (contentType != null && (contentType.StartsWith("image/")
|
||||
|| contentType.Equals("application/zip", StringComparison.OrdinalIgnoreCase)
|
||||
|| contentType.Equals("application/x-gzip", StringComparison.OrdinalIgnoreCase)))
|
||||
if (contentType != null && (contentType.StartsWith("image/") ||
|
||||
binaryContentTypes
|
||||
.Any(item => item.Equals(contentType,StringComparison.OrdinalIgnoreCase))))
|
||||
{
|
||||
responseBody = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user