Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Pass Uri.IdnHost to WinHttpConnect (#28849)
Browse files Browse the repository at this point in the history
* pass IdnHost

* add manual functional test

* cleanup

* fix comment

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* fix IPv6 IdnHost

* address PR feedback
  • Loading branch information
MarcoRossignoli authored and Caesar1995 committed Apr 17, 2018
1 parent 4036846 commit b2893f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ private async void StartRequest(WinHttpRequestState state)
// Specify an HTTP server.
connectHandle = Interop.WinHttp.WinHttpConnect(
_sessionHandle,
state.RequestMessage.RequestUri.Host,
state.RequestMessage.RequestUri.HostNameType == UriHostNameType.IPv6 ? "[" + state.RequestMessage.RequestUri.IdnHost + "]" : state.RequestMessage.RequestUri.IdnHost,
(ushort)state.RequestMessage.RequestUri.Port,
0);
ThrowOnInvalidHandle(connectHandle, nameof(Interop.WinHttp.WinHttpConnect));
Expand Down
17 changes: 17 additions & 0 deletions src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,23 @@ await server.AcceptConnectionSendCustomResponseAndCloseAsync(
});
}

[OuterLoop]
[Fact]
public async Task GetAsync_UnicodeHostName_SuccessStatusCodeInResponse()
{
HttpClientHandler handler = CreateHttpClientHandler();
using (var client = new HttpClient(handler))
{
// international version of the Starbucks website
// punycode: xn--oy2b35ckwhba574atvuzkc.com
string server = "http://\uc2a4\ud0c0\ubc85\uc2a4\ucf54\ub9ac\uc544.com";
using (HttpResponseMessage response = await client.GetAsync(server))
{
response.EnsureSuccessStatusCode();
}
}
}

#region Post Methods Tests

[OuterLoop] // TODO: Issue #11345
Expand Down

0 comments on commit b2893f0

Please sign in to comment.