Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispose server connection after client has been disposed #56720

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
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,6 @@ public async Task ConnectCallback_UseMemoryBuffer_Success(bool useSsl)
}

[ConditionalTheory(nameof(PlatformSupportsUnixDomainSockets))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/44183", TestPlatforms.Windows)]
[InlineData(true)]
[InlineData(false)]
public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl)
Expand All @@ -2584,26 +2583,26 @@ public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl)
return new NetworkStream(clientSocket, ownsSocket: true);
};

GenericLoopbackConnection loopbackConnection;
using (HttpClient client = CreateHttpClient(handler))
{
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact;

Task<string> clientTask = client.GetStringAsync($"{(options.UseSsl ? "https" : "http")}://{guid}/foo");

Socket serverSocket = await listenSocket.AcceptAsync();
using (GenericLoopbackConnection loopbackConnection = await LoopbackServerFactory.CreateConnectionAsync(socket: null, new NetworkStream(serverSocket, ownsSocket: true), options))
{
await loopbackConnection.InitializeConnectionAsync();
loopbackConnection = await LoopbackServerFactory.CreateConnectionAsync(socket: null, new NetworkStream(serverSocket, ownsSocket: true), options);
await loopbackConnection.InitializeConnectionAsync();

HttpRequestData requestData = await loopbackConnection.ReadRequestDataAsync();
Assert.Equal("/foo", requestData.Path);
HttpRequestData requestData = await loopbackConnection.ReadRequestDataAsync();
Assert.Equal("/foo", requestData.Path);

await loopbackConnection.SendResponseAsync(content: "foo");
await loopbackConnection.SendResponseAsync(content: "foo");

string response = await clientTask;
Assert.Equal("foo", response);
}
string response = await clientTask;
Assert.Equal("foo", response);
}
loopbackConnection.Dispose();
}

[Theory]
Expand Down