Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit 8b33423

Browse files
committed
Merge pull request #10 from Cheesebaron/patch-1
Only try buffer content if present
2 parents 1741b0d + 14443dc commit 8b33423

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Microsoft.AspNet.WebApi.MessageHandlers.Compression/ClientCompressionHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
9999

100100
try
101101
{
102-
// Buffer content for further processing
103-
await response.Content.LoadIntoBufferAsync();
102+
if (response.Content != null)
103+
// Buffer content for further processing
104+
await response.Content.LoadIntoBufferAsync();
105+
else
106+
process = false;
104107
}
105108
catch (Exception ex)
106109
{
@@ -184,4 +187,4 @@ private async Task DecompressResponse(HttpResponseMessage response)
184187
}
185188
}
186189
}
187-
}
190+
}

src/Microsoft.AspNet.WebApi.MessageHandlers.Compression/ServerCompressionHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
101101

102102
try
103103
{
104-
// Buffer content for further processing
105-
await response.Content.LoadIntoBufferAsync();
104+
if (response.Content != null)
105+
// Buffer content for further processing
106+
await response.Content.LoadIntoBufferAsync();
107+
else
108+
process = false;
106109
}
107110
catch (Exception ex)
108111
{
@@ -184,4 +187,4 @@ private async Task DecompressRequest(HttpRequestMessage request)
184187
}
185188
}
186189
}
187-
}
190+
}

0 commit comments

Comments
 (0)