Skip to content

Commit

Permalink
change using in ConnectCallback_UseUnixDomainSocket_Success (#44366)
Browse files Browse the repository at this point in the history
  • Loading branch information
wfurt committed Nov 8, 2020
1 parent 77f1def commit 894b730
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2476,22 +2476,26 @@ public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl)
return new NetworkStream(clientSocket, ownsSocket: true);
};

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

Task<string> clientTask = client.GetStringAsync($"{(options.UseSsl ? "https" : "http")}://{guid}/foo");
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();
Socket serverSocket = await listenSocket.AcceptAsync();
using (GenericLoopbackConnection 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);
}
}
}

[Theory]
Expand Down

0 comments on commit 894b730

Please sign in to comment.