Skip to content

Commit

Permalink
feature(IpfsClient): Efficient processing of large/continuous responses
Browse files Browse the repository at this point in the history
Start processing the response when the headers are received.  This also stops buffering of large content.
  • Loading branch information
richardschneider committed Oct 23, 2017
1 parent f2e0524 commit 81fea3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/IpfsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ public async Task<string> PostCommandAsync(string command, string arg = null, pa
var url = BuildCommand(command, arg, options);
if (log.IsDebugEnabled)
log.Debug("POST " + url.ToString());
using (var response = await Api().PostAsync(url, null))
var request = new HttpRequestMessage(HttpMethod.Post, url);

using (var response = await Api().SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
{
await ThrowOnErrorAsync(response);
var body = await response.Content.ReadAsStringAsync();
Expand Down Expand Up @@ -355,7 +357,9 @@ public async Task<Stream> PostDownloadAsync(string command, string arg = null, p
var url = BuildCommand(command, arg, options);
if (log.IsDebugEnabled)
log.Debug("POST " + url.ToString());
var response = await Api().PostAsync(url, null);
var request = new HttpRequestMessage(HttpMethod.Post, url);

var response = await Api().SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
await ThrowOnErrorAsync(response);
return await response.Content.ReadAsStreamAsync();
}
Expand Down

0 comments on commit 81fea3a

Please sign in to comment.