Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ string EncodeUrl (Uri url)
try {
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $" connecting");
await httpConnection.ConnectAsync ().ConfigureAwait (false);
await Task.WhenAny(httpConnection.ConnectAsync(),Task.Run(()=> { cancellationToken.WaitHandle.WaitOne(); })).ConfigureAwait(false);
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $" connected");
} catch (Java.Net.ConnectException ex) {
Expand All @@ -265,7 +265,16 @@ string EncodeUrl (Uri url)
cancellationToken.Register (httpConnection.Disconnect);

if (httpConnection.DoOutput) {
await request.Content.CopyToAsync (httpConnection.OutputStream).ConfigureAwait (false);
using (var stream = await request.Content.ReadAsStreamAsync())
{
await stream.CopyToAsync(httpConnection.OutputStream, 4096, cancellationToken).ConfigureAwait(false);
}
}

if (cancellationToken.IsCancellationRequested)
{
httpConnection.Disconnect();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here is weird. Is there an extra tab on this line and the following?

cancellationToken.ThrowIfCancellationRequested();
}

var statusCode = await Task.Run (() => (HttpStatusCode)httpConnection.ResponseCode).ConfigureAwait (false);
Expand Down