Unverified Commit a4c995a3 by Ryan Baxter Committed by GitHub

Disable following redirects in SimpleHostRoutingFilter. Fixes #2578. (#2608)

parent 9deab33d
......@@ -220,7 +220,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
return httpClientFactory.createBuilder().
setDefaultRequestConfig(requestConfig).
setConnectionManager(this.connectionManager).build();
setConnectionManager(this.connectionManager).disableRedirectHandling().build();
}
private CloseableHttpResponse forward(CloseableHttpClient httpclient, String verb,
......
......@@ -196,6 +196,20 @@ public class SimpleHostRoutingFilterTests {
assertTrue("Get 1".equals(responseString));
}
@Test
public void redirectTest() throws Exception {
setupContext();
InputStreamEntity inputStreamEntity = new InputStreamEntity(new ByteArrayInputStream(new byte[]{}));
HttpRequest httpRequest = getFilter().buildHttpRequest("GET", "/app/redirect", inputStreamEntity,
new LinkedMultiValueMap<String, String>(), new LinkedMultiValueMap<String, String>(), new MockHttpServletRequest());
CloseableHttpResponse response = getFilter().newClient().execute(new HttpHost("localhost", this.port), httpRequest);
assertEquals(302, response.getStatusLine().getStatusCode());
String responseString = copyToString(response.getEntity().getContent(), Charset.forName("UTF-8"));
assertTrue(response.getLastHeader("Location").getValue().contains("/app/get/5"));
}
@Test
public void zuulHostKeysUpdateHttpClient() {
setupContext();
......@@ -259,6 +273,12 @@ class SampleApplication {
public String getString(@PathVariable String id, HttpServletResponse response) throws IOException {
return "Get " + id;
}
@RequestMapping(value = "/redirect", method = RequestMethod.GET)
public String redirect(HttpServletResponse response) throws IOException {
response.sendRedirect("/app/get/5");
return null;
}
}
class GZIPCompression {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment