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
Fix HttpClient sending fragment portion of uri on request (#32574)
Browse files Browse the repository at this point in the history
Fixes #32378
  • Loading branch information
MarcoRossignoli authored and davidsh committed Oct 4, 2018
1 parent f420707 commit 87a944a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public async Task<HttpResponseMessage> SendAsyncCore(HttpRequestMessage request,
await WriteDecimalInt32Async(request.RequestUri.Port).ConfigureAwait(false);
}
}
await WriteStringAsync(request.RequestUri.GetComponents(UriComponents.PathAndQuery | UriComponents.Fragment, UriFormat.UriEscaped)).ConfigureAwait(false);
await WriteStringAsync(request.RequestUri.PathAndQuery).ConfigureAwait(false);
}

// Fall back to 1.1 for all versions other than 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,8 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
}
}

[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Doesn't send fragments")]
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "UAP HTTP stack doesn't send fragments")]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Doesn't handle fragments according to https://tools.ietf.org/html/rfc7231#section-7.1.2")]
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Doesn't handle fragments according to https://tools.ietf.org/html/rfc7231#section-7.1.2")]
[Theory]
[InlineData("#origFragment", "", "#origFragment", false)]
[InlineData("#origFragment", "", "#origFragment", true)]
Expand All @@ -1215,8 +1215,7 @@ public async Task GetAsync_AllowAutoRedirectTrue_RetainsOriginalFragmentIfApprop
{
if (IsCurlHandler)
{
// Starting with libcurl 7.20, "fragment part of URLs are no longer sent to the server".
// So CurlHandler doesn't send fragments.
// libcurl doesn't append fragment component to CURLINFO_EFFECTIVE_URL after redirect
return;
}

Expand Down Expand Up @@ -1261,7 +1260,7 @@ await LoopbackServer.CreateServerAsync(async (origServer, origUrl) =>
Assert.NotEmpty(secondRequest.Result);
string[] statusLineParts = secondRequest.Result[0].Split(' ');
Assert.Equal(3, statusLineParts.Length);
Assert.Equal(expectedUrl.GetComponents(UriComponents.PathAndQuery | UriComponents.Fragment, UriFormat.SafeUnescaped), statusLineParts[1]);
Assert.Equal(expectedUrl.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped), statusLineParts[1]);

// Make sure the request message was updated with the correct redirected location.
using (HttpResponseMessage response = await getResponse)
Expand Down

0 comments on commit 87a944a

Please sign in to comment.