@Test public void testHost() { when(request.getHeader(DefaultApiRequestParser.FORWARDED_PROTO_HEADER)).thenReturn("https"); when(request.getHeader(DefaultApiRequestParser.FORWARDED_PORT_HEADER)).thenReturn("1234"); String url = parser.parseRequestUrl(null, request); assertEquals("https: when(request.getHeader(DefaultApiRequestParser.FORWARDED_PORT_HEADER)).thenReturn(null); url = parser.parseRequestUrl(null, request); assertEquals("https: when(request.getHeader(DefaultApiRequestParser.FORWARDED_PROTO_HEADER)).thenReturn("https"); when(request.getHeader(DefaultApiRequestParser.HOST_HEADER)).thenReturn("hostfoo:1111"); when(request.getHeader(DefaultApiRequestParser.FORWARDED_PORT_HEADER)).thenReturn("1234"); url = parser.parseRequestUrl(null, request); assertEquals("https: when(request.getRequestURI()).thenReturn("/v1/instances/"); url = parser.parseRequestUrl(null, request); assertEquals("https: }
protected String parseRequestUrl(ApiRequest apiRequest, HttpServletRequest request) { String requestUrl = getOverrideHeader(request, overrideUrlHeader, null); if (requestUrl != null) { String[] parts = requestUrl.split("\\?", 2); return parts[0]; } requestUrl = getUrlFromStandardHeaders(request); if (requestUrl != null) { return requestUrl; } return request.getRequestURL().toString(); }
DefaultApiRequestParser implements ApiRequestParser { protected String parseRequestUrl(ApiRequest apiRequest, HttpServletRequest request) { String requestUrl = getOverrideHeader(request, overrideUrlHeader, null); if (requestUrl != null) { String[] parts = requestUrl.split("\\?", 2); return parts[0]; } requestUrl = getUrlFromStandardHeaders(request); if (requestUrl != null) { return requestUrl; } return request.getRequestURL().toString(); } }
DefaultApiRequestParser implements ApiRequestParser { protected String parseRequestUrl(ApiRequest apiRequest, HttpServletRequest request) { String requestUrl = getOverrideHeader(request, overrideUrlHeader, null); if (requestUrl != null) { String[] parts = requestUrl.split("\\?", 2); return parts[0]; } requestUrl = getUrlFromStandardHeaders(request); if (requestUrl != null) { return requestUrl; } return request.getRequestURL().toString(); }  }
DefaultApiRequestParser implements ApiRequestParser { protected String parseRequestUrl(ApiRequest apiRequest, HttpServletRequest request) { String requestUrl = getOverrideHeader(request, overrideUrlHeader, null); if (requestUrl != null) { String[] parts = requestUrl.split("\\?", 2); return parts[0]; } requestUrl = getUrlFromStandardHeaders(request); if (requestUrl != null) { return requestUrl; } return request.getRequestURL().toString(); }  @Override boolean parse(ApiRequest apiRequest); @Override String parseVersion(String servletPath); @PostConstruct void init(); boolean isHttpsPort(String host, String port); Set<String> getAllowedFormats(); void setAllowedFormats(Set<String> allowedFormats); boolean isAllowClientOverrideHeaders(); void setAllowClientOverrideHeaders(boolean allowClientOverrideHeaders); String getTrimPrefix(); void setTrimPrefix(String trimPrefix); }
DefaultApiRequestParser implements ApiRequestParser { protected String parseRequestUrl(ApiRequest apiRequest, HttpServletRequest request) { String requestUrl = getOverrideHeader(request, overrideUrlHeader, null); if (requestUrl != null) { String[] parts = requestUrl.split("\\?", 2); return parts[0]; } requestUrl = getUrlFromStandardHeaders(request); if (requestUrl != null) { return requestUrl; } return request.getRequestURL().toString(); }  @Override boolean parse(ApiRequest apiRequest); @Override String parseVersion(String servletPath); @PostConstruct void init(); boolean isHttpsPort(String host, String port); Set<String> getAllowedFormats(); void setAllowedFormats(Set<String> allowedFormats); boolean isAllowClientOverrideHeaders(); void setAllowClientOverrideHeaders(boolean allowClientOverrideHeaders); String getTrimPrefix(); void setTrimPrefix(String trimPrefix); static final String DEFAULT_OVERRIDE_URL_HEADER; static final String DEFAULT_OVERRIDE_CLIENT_IP_HEADER; static final String FORWARDED_FOR_HEADER; static final String FORWARDED_HOST_HEADER; static final String FORWARDED_PROTO_HEADER; static final String FORWARDED_PORT_HEADER; static final String HOST_HEADER; static final String HTML; static final String JSON; }