Skip to content

Commit 7bfec48

Browse files
committed
More cancellation checks
1 parent 34c89a8 commit 7bfec48

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.Legacy.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ Task ConnectAsync (HttpURLConnection httpConnection, CancellationToken ct)
361361
protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage request, HttpURLConnection httpConnection, CancellationToken cancellationToken)
362362
{
363363
using (var stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false)) {
364+
cancellationToken.ThrowIfCancellationRequested ();
364365
try {
365366
await stream.CopyToAsync(httpConnection.OutputStream!, 4096, cancellationToken).ConfigureAwait(false);
366367
} catch (ObjectDisposedException ex) {
@@ -387,6 +388,7 @@ protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage req
387388
// See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
388389
//
389390
if (stream.CanSeek) {
391+
cancellationToken.ThrowIfCancellationRequested ();
390392
try {
391393
stream.Seek (0, SeekOrigin.Begin);
392394
} catch (ObjectDisposedException ex) {

src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage req
537537
return;
538538

539539
using (var stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false)) {
540-
await stream.CopyToAsync(httpConnection.OutputStream!, 4096, cancellationToken).ConfigureAwait(false);
541540
cancellationToken.ThrowIfCancellationRequested ();
542541
try {
543542
await stream.CopyToAsync(httpConnection.OutputStream!, 4096, cancellationToken).ConfigureAwait(false);
@@ -565,6 +564,7 @@ protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage req
565564
// See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
566565
//
567566
if (stream.CanSeek) {
567+
cancellationToken.ThrowIfCancellationRequested ();
568568
try {
569569
stream.Seek (0, SeekOrigin.Begin);
570570
} catch (ObjectDisposedException ex) {

0 commit comments

Comments
 (0)