ok2c commented on code in PR #904:
URL:
https://github.com/apache/httpcomponents-client/pull/904#discussion_r4376751765
##########
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 The test is perfectly fine. What I am saying in a real world message
exchange such redirect is likely to cause an infinite redirect loop. This is
just a remark.
--
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]