ok2c commented on code in PR #904:
URL:
https://github.com/apache/httpcomponents-client/pull/904#discussion_r4376691036
##########
httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java:
##########
@@ -163,6 +163,28 @@ void testGetLocationUriRelative() throws Exception {
Assertions.assertEquals(URI.create("http://localhost/stuff"), uri);
}
+ @Test
+ void testGetLocationUriRelativeQueryOnly() throws Exception {
+ final DefaultRedirectStrategy redirectStrategy = new
DefaultRedirectStrategy();
+ final HttpClientContext context = HttpClientContext.create();
+ final HttpGet httpget = new
HttpGet("http://localhost/stuff/index.html?a=1");
+ final HttpResponse response = new
BasicHttpResponse(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect");
+ response.addHeader("Location", "?b=2");
+ final URI uri = redirectStrategy.getLocationURI(httpget, response,
context);
+
Assertions.assertEquals(URI.create("http://localhost/stuff/index.html?b=2"),
uri);
+ }
+
+ @Test
+ void testGetLocationUriFragmentOnly() throws Exception {
+ final DefaultRedirectStrategy redirectStrategy = new
DefaultRedirectStrategy();
+ final HttpClientContext context = HttpClientContext.create();
+ final HttpGet httpget = new
HttpGet("http://localhost/stuff/index.html?a=1");
+ final HttpResponse response = new
BasicHttpResponse(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect");
+ response.addHeader("Location", "#fragment");
Review Comment:
@wleeaf Please note the fragment will get stripped upon request execution to
the redirect location.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]