I got a HttpServletRequest request in my Spring Servlet which I would like to forward AS-IS (i.e. GET or POST content) to a different server.
HttpServletRequest
What would be
@RequestMapping(value = "/**") public ResponseEntity route(HttpServletRequest request) throws IOException { String body = IOUtils.toString(request.getInputStream(), Charset.forName(request.getCharacterEncoding())); try { ResponseEntity exchange = restTemplate.exchange(firstUrl + request.getRequestURI(), HttpMethod.valueOf(request.getMethod()), new HttpEntity<>(body), Object.class, request.getParameterMap()); return exchange; } catch (final HttpClientErrorException e) { return new ResponseEntity<>(e.getResponseBodyAsByteArray(), e.getResponseHeaders(), e.getStatusCode()); } }