@@ -536,30 +536,29 @@ protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage req
536536 if ( request . Content is null )
537537 return ;
538538
539- using ( var stream = await request . Content . ReadAsStreamAsync ( ) . ConfigureAwait ( false ) ) {
540- await stream . CopyToAsync ( httpConnection . OutputStream ! , 4096 , cancellationToken ) . ConfigureAwait ( false ) ;
541-
542- //
543- // Rewind the stream to beginning in case the HttpContent implementation
544- // will be accessed again (e.g. after redirect) and it keeps its stream
545- // open behind the scenes instead of recreating it on the next call to
546- // ReadAsStreamAsync. If we don't rewind it, the ReadAsStreamAsync
547- // call above will throw an exception as we'd be attempting to read an
548- // already "closed" stream (that is one whose Position is set to its
549- // end).
550- //
551- // This is not a perfect solution since the HttpContent may do weird
552- // things in its implementation, but it's better than copying the
553- // content into a buffer since we have no way of knowing how the data is
554- // read or generated and also we don't want to keep potentially large
555- // amounts of data in memory (which would happen if we read the content
556- // into a byte[] buffer and kept it cached for re-use on redirect).
557- //
558- // See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
559- //
560- if ( stream . CanSeek )
561- stream . Seek ( 0 , SeekOrigin . Begin ) ;
562- }
539+ var stream = await request . Content . ReadAsStreamAsync ( ) . ConfigureAwait ( false ) ;
540+ await stream . CopyToAsync ( httpConnection . OutputStream ! , 4096 , cancellationToken ) . ConfigureAwait ( false ) ;
541+
542+ //
543+ // Rewind the stream to beginning in case the HttpContent implementation
544+ // will be accessed again (e.g. after redirect) and it keeps its stream
545+ // open behind the scenes instead of recreating it on the next call to
546+ // ReadAsStreamAsync. If we don't rewind it, the ReadAsStreamAsync
547+ // call above will throw an exception as we'd be attempting to read an
548+ // already "closed" stream (that is one whose Position is set to its
549+ // end).
550+ //
551+ // This is not a perfect solution since the HttpContent may do weird
552+ // things in its implementation, but it's better than copying the
553+ // content into a buffer since we have no way of knowing how the data is
554+ // read or generated and also we don't want to keep potentially large
555+ // amounts of data in memory (which would happen if we read the content
556+ // into a byte[] buffer and kept it cached for re-use on redirect).
557+ //
558+ // See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
559+ //
560+ if ( stream . CanSeek )
561+ stream . Seek ( 0 , SeekOrigin . Begin ) ;
563562 }
564563
565564 internal Task WriteRequestContentToOutputInternal ( HttpRequestMessage request , HttpURLConnection httpConnection , CancellationToken cancellationToken )
0 commit comments