@Test void test_Location_header_without_forwarded() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("172.19.0.4"); request.setRequestURI("/v1/rest"); AbstractWebController testee = new AbstractWebController(){}; assertThat(testee.getLocationURIForCreatedResource(request, "4711").toASCIIString()).isEqualTo("http: }
protected URI getLocationURIForCreatedResource(HttpServletRequest req, String objId) { String proto = req.getHeader("x-forwarded-proto"); String host = req.getHeader("x-forwarded-host"); StringBuilder url = new StringBuilder(); if (proto != null && host != null) { url.append(proto.endsWith(": } else { url.append(req.getScheme().endsWith(": .append(req.getServerName()).append(":") .append(req.getServerPort()); } String prefix = req.getHeader("x-forwarded-prefix"); if (prefix != null) { url.append(prefix); } url.append(req.getRequestURI()); url.append("/{objId}/"); return new UriTemplate(url.toString()).expand(objId); }
AbstractWebController { protected URI getLocationURIForCreatedResource(HttpServletRequest req, String objId) { String proto = req.getHeader("x-forwarded-proto"); String host = req.getHeader("x-forwarded-host"); StringBuilder url = new StringBuilder(); if (proto != null && host != null) { url.append(proto.endsWith(": } else { url.append(req.getScheme().endsWith(": .append(req.getServerName()).append(":") .append(req.getServerPort()); } String prefix = req.getHeader("x-forwarded-prefix"); if (prefix != null) { url.append(prefix); } url.append(req.getRequestURI()); url.append("/{objId}/"); return new UriTemplate(url.toString()).expand(objId); } }
AbstractWebController { protected URI getLocationURIForCreatedResource(HttpServletRequest req, String objId) { String proto = req.getHeader("x-forwarded-proto"); String host = req.getHeader("x-forwarded-host"); StringBuilder url = new StringBuilder(); if (proto != null && host != null) { url.append(proto.endsWith(": } else { url.append(req.getScheme().endsWith(": .append(req.getServerName()).append(":") .append(req.getServerPort()); } String prefix = req.getHeader("x-forwarded-prefix"); if (prefix != null) { url.append(prefix); } url.append(req.getRequestURI()); url.append("/{objId}/"); return new UriTemplate(url.toString()).expand(objId); }  }
AbstractWebController { protected URI getLocationURIForCreatedResource(HttpServletRequest req, String objId) { String proto = req.getHeader("x-forwarded-proto"); String host = req.getHeader("x-forwarded-host"); StringBuilder url = new StringBuilder(); if (proto != null && host != null) { url.append(proto.endsWith(": } else { url.append(req.getScheme().endsWith(": .append(req.getServerName()).append(":") .append(req.getServerPort()); } String prefix = req.getHeader("x-forwarded-prefix"); if (prefix != null) { url.append(prefix); } url.append(req.getRequestURI()); url.append("/{objId}/"); return new UriTemplate(url.toString()).expand(objId); }  @ExceptionHandler({IllegalArgumentException.class}) ResponseEntity<Response<?>> IllegalArgumentException(IllegalArgumentException ex); }
AbstractWebController { protected URI getLocationURIForCreatedResource(HttpServletRequest req, String objId) { String proto = req.getHeader("x-forwarded-proto"); String host = req.getHeader("x-forwarded-host"); StringBuilder url = new StringBuilder(); if (proto != null && host != null) { url.append(proto.endsWith(": } else { url.append(req.getScheme().endsWith(": .append(req.getServerName()).append(":") .append(req.getServerPort()); } String prefix = req.getHeader("x-forwarded-prefix"); if (prefix != null) { url.append(prefix); } url.append(req.getRequestURI()); url.append("/{objId}/"); return new UriTemplate(url.toString()).expand(objId); }  @ExceptionHandler({IllegalArgumentException.class}) ResponseEntity<Response<?>> IllegalArgumentException(IllegalArgumentException ex);  }