@Test (dataProvider = "requestProvider") public void testProxyRequest(String method) throws Exception { when(request.getMethod()).thenReturn(method); Response response = client.proxyRequest(request, targetUri + "/"); int status = response.getStatus(); assertEquals(response.getEntity().toString(), RESPONSE_CONTENT); assertEquals(status, 200); assertEquals(response.getHeaderString(TEST_HEADER_NAME), TEST_HEADER_VALUE); }
@Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); }
ApacheHttpComponentProxyClient implements ProxyClient { @Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); } }
ApacheHttpComponentProxyClient implements ProxyClient { @Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); } ApacheHttpComponentProxyClient(); }
ApacheHttpComponentProxyClient implements ProxyClient { @Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); } ApacheHttpComponentProxyClient(); @Override Response proxyRequest(ContainerRequestContext request, String baseUri); }
ApacheHttpComponentProxyClient implements ProxyClient { @Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); } ApacheHttpComponentProxyClient(); @Override Response proxyRequest(ContainerRequestContext request, String baseUri);  }