don't send an entity on DELETE's through RibbonRoutingFilter

fixes gh-73
This commit is contained in:
Spencer Gibb
2014-11-26 13:38:26 -07:00
parent c28b3252fb
commit 9add6f1edf
2 changed files with 6 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ public class RibbonRoutingFilter extends SpringFilter {
getBean(RibbonClientPreprocessor.class).preprocess(serviceId);
//TODO: update to ribbon-rxnetty when available
RestClient restClient = getBean(SpringClientFactory.class).namedClient(serviceId, RestClient.class);
String uri = request.getRequestURI();
@@ -199,6 +200,10 @@ public class RibbonRoutingFilter extends SpringFilter {
private InputStream getRequestBody(HttpServletRequest request) {
InputStream requestEntity = null;
//ApacheHttpClient4Handler does not support body in delete requests
if (request.getMethod().equals("DELETE")) {
return null;
}
try {
requestEntity = (InputStream) RequestContext.getCurrentContext().get(
"requestEntity");

View File

@@ -32,7 +32,7 @@ public class SampleZuulProxyApplicationTests {
private ZuulHandlerMapping mapping;
@Test
public void deleteOnSelf() {
public void deleteOnSelfViaSimpleHostRoutingFilter() {
routes.getRoutes().put("/self/**", "http://localhost:" + port + "/local");
mapping.registerHandlers(routes.getRoutes());
ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + port + "/self/1",