Skip to content

Commit

Permalink
Support cancellation token in streams
Browse files Browse the repository at this point in the history
  • Loading branch information
jakublabno committed Jan 10, 2025
1 parent 4a8cb90 commit 2b16000
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions smsapi/NativeHttpClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public static async Task<HttpResponseEntity> SendRequest(
case RequestMethod.GET:
var getResponse = await httpClient.GetAsync(uri, cancellationToken);

return new HttpResponseEntity(getResponse.Content.ReadAsStreamAsync(cancellationToken), getResponse.StatusCode);
return new HttpResponseEntity(getResponse.Content.ReadAsStreamAsync(), getResponse.StatusCode);
case RequestMethod.POST:
httpContent = ConvertRequestDataToHttpContent(actionContentType, body, files);
var postResponse = await httpClient.PostAsync(uri, httpContent, cancellationToken);

return new HttpResponseEntity(postResponse.Content.ReadAsStreamAsync(cancellationToken), postResponse.StatusCode);
return new HttpResponseEntity(postResponse.Content.ReadAsStreamAsync(), postResponse.StatusCode);
case RequestMethod.PUT:
httpContent = ConvertRequestDataToHttpContent(actionContentType, body, files);
var putResponse = await httpClient.PutAsync(uri, httpContent, cancellationToken);

return new HttpResponseEntity(putResponse.Content.ReadAsStreamAsync(cancellationToken), putResponse.StatusCode);
return new HttpResponseEntity(putResponse.Content.ReadAsStreamAsync(), putResponse.StatusCode);
case RequestMethod.DELETE:
var deleteResult = await httpClient.DeleteAsync(uri, cancellationToken);

return new HttpResponseEntity(deleteResult.Content.ReadAsStreamAsync(cancellationToken), deleteResult.StatusCode);
return new HttpResponseEntity(deleteResult.Content.ReadAsStreamAsync(), deleteResult.StatusCode);
default:
throw new ArgumentOutOfRangeException(nameof(method), method, null);
}
Expand Down

0 comments on commit 2b16000

Please sign in to comment.