You've already forked linux-packaging-mono
Imported Upstream version 6.8.0.95
Former-commit-id: f9d71b03d311b37638cba87ec50db50e194b00ba
This commit is contained in:
parent
0721831ed1
commit
6ab90dd8aa
@@ -193,6 +193,19 @@ namespace System.Net.Http
|
||||
_readAheadTask = new ValueTask<int>(0);
|
||||
}
|
||||
|
||||
#if MONO
|
||||
if (!_readAheadTask.Value.IsCompleted && _socket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _socket.Poll(0, SelectMode.SelectRead);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return _readAheadTask.Value.IsCompleted; // equivalent to polling
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,65 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using System.Net.Test.Common;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if !MONO
|
||||
using Microsoft.DotNet.XUnitExtensions;
|
||||
using Microsoft.DotNet.RemoteExecutor;
|
||||
#endif
|
||||
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace System.Net.Http.Functional.Tests
|
||||
{
|
||||
using Configuration = System.Net.Test.Common.Configuration;
|
||||
|
||||
public class HttpClientHandler_ConnectionReuse_Test : HttpClientTestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task Test17710()
|
||||
{
|
||||
using (HttpClient client = CreateHttpClient())
|
||||
{
|
||||
const string text = "THE POST CONTENT";
|
||||
var data = new StringContent(text);
|
||||
await LoopbackServer.CreateServerAsync(async (server, url) =>
|
||||
{
|
||||
Task serverTask1 = server.AcceptConnectionAsync(async connection1 =>
|
||||
{
|
||||
await connection1.ReadRequestHeaderAsync();
|
||||
var buffer = new char[text.Length];
|
||||
var ret = await connection1.Reader.ReadBlockAsync(buffer, 0, buffer.Length);
|
||||
Assert.Equal(text.Length, ret);
|
||||
await connection1.SendResponseAsync(HttpStatusCode.OK, null, "hello");
|
||||
await Task.Delay(500);
|
||||
connection1.Dispose();
|
||||
});
|
||||
|
||||
await client.PostAsync(url, data);
|
||||
|
||||
await serverTask1;
|
||||
|
||||
Task serverTask2 = server.AcceptConnectionAsync(async connection2 =>
|
||||
{
|
||||
await connection2.ReadRequestHeaderAsync();
|
||||
var buffer = new char[text.Length];
|
||||
var ret = await connection2.Reader.ReadBlockAsync(buffer, 0, buffer.Length);
|
||||
Assert.Equal(text.Length, ret);
|
||||
await connection2.SendResponseAsync(HttpStatusCode.OK, null, "hello");
|
||||
await Task.Delay(500);
|
||||
connection2.Dispose();
|
||||
});
|
||||
|
||||
await client.PostAsync(url, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -187,6 +187,15 @@ namespace System.Net.Sockets
|
||||
|
||||
// Keep track of this because it will be overwritten by AttemptConnection
|
||||
SocketError currentFailure = args.SocketError;
|
||||
#if MONO
|
||||
// Make sure we're always resetting the Mono-specific `in_progress` field when
|
||||
// re-attempting a connection.
|
||||
// If a previous connection failed asynchronously, then it will already have been
|
||||
// resetted, but not on synchronous connection failures (such as for instance, the
|
||||
// host not supporting IPv6 or the network being down).
|
||||
// This should fix https://github.com/mono/mono/issues/18030.
|
||||
args.in_progress = 0;
|
||||
#endif
|
||||
Exception connectException = AttemptConnection();
|
||||
|
||||
if (connectException == null)
|
||||
|
Reference in New Issue
Block a user