private static <T> T handleProxyException(Request request, ProxyException e) { log.warn(e, "Proxy request failed: %s %s", request.getMethod(), request.getUri()); throw badRequest(BAD_GATEWAY, e.getMessage()); }
if (request.getMethod().equals("DELETE")) { assertEquals(parts.size(), 1); return new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), new byte[0]);
@Override public Response handle(Request request) if (request.getMethod().equalsIgnoreCase("DELETE")) { return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]);
private static <T> T handleProxyException(Request request, ProxyException e) { log.warn(e, "Proxy request failed: %s %s", request.getMethod(), request.getUri()); throw badRequest(BAD_GATEWAY, e.getMessage()); }
Invocation invocation; if (request.getBodyGenerator() == null) { invocation = invocationBuilder.build(request.getMethod()); byte[] bytes = byteArrayOutputStream.toByteArray(); Entity<byte[]> entity = Entity.entity(bytes, (String) getOnlyElement(requestHeaders.get("Content-Type"))); invocation = invocationBuilder.build(request.getMethod(), entity); log.warn(exception.getCause(), "%-8s %s -> Exception", request.getMethod(), request.getUri()); log.warn(throwable, "%-8s %s -> Fail", request.getMethod(), request.getUri()); log.warn("%-8s %s -> OK", request.getMethod(), request.getUri());
@Test public void testRequestBuilder() { Request request = createRequest(); assertEquals(request.getMethod(), "GET"); assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR); assertEquals(request.getUri(), URI.create("http://example.com")); assertEquals(request.getHeaders(), ImmutableListMultimap.of( "newheader", "withvalue", "anotherheader", "anothervalue")); }
@Test public void testRequestBuilder() { Request request = createRequest(); assertEquals(request.getMethod(), "GET"); assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR); assertEquals(request.getUri(), URI.create("http://example.com")); assertEquals(request.getHeaders(), ImmutableListMultimap.of( "newheader", "withvalue", "anotherheader", "anothervalue")); assertFalse(request.isFollowRedirects()); }
@Test public void testRequestBuilder() { Request request = createRequest(); assertEquals(request.getMethod(), "GET"); assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR); assertEquals(request.getUri(), URI.create("http://example.com")); assertEquals(request.getHeaders(), ImmutableListMultimap.of( "newheader", "withvalue", "anotherheader", "anothervalue")); }
@Test public void testRequestBuilder() { Request request = createRequest(); assertEquals(request.getMethod(), "GET"); assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR); assertEquals(request.getUri(), URI.create("http://example.com")); assertEquals(request.getHeaders(), ImmutableListMultimap.of( "newheader", "withvalue", "anotherheader", "anothervalue")); assertFalse(request.isFollowRedirects()); }
Invocation invocation; if (request.getBodyGenerator() == null) { invocation = invocationBuilder.build(request.getMethod()); byte[] bytes = byteArrayOutputStream.toByteArray(); Entity<byte[]> entity = Entity.entity(bytes, (String) getOnlyElement(requestHeaders.get("Content-Type"))); invocation = invocationBuilder.build(request.getMethod(), entity); log.warn(exception.getCause(), "%-8s %s -> Exception", request.getMethod(), request.getUri()); log.warn(throwable, "%-8s %s -> Fail", request.getMethod(), request.getUri()); log.warn("%-8s %s -> OK", request.getMethod(), request.getUri());
static void recordRequestComplete(RequestStats requestStats, Request request, long requestStart, JettyResponse response, long responseStart) { if (response == null) { return; } Duration responseProcessingTime = Duration.nanosSince(responseStart); Duration requestProcessingTime = new Duration(responseStart - requestStart, NANOSECONDS); requestStats.recordResponseReceived(request.getMethod(), response.getStatusCode(), response.getBytesRead(), response.getBytesRead(), requestProcessingTime, responseProcessingTime); } }
public static Builder fromRequest(Request request) { return new Builder() .setUri(request.getUri()) .setMethod(request.getMethod()) .addHeaders(request.getHeaders()) .setBodyGenerator(request.getBodyGenerator()) .setFollowRedirects(request.isFollowRedirects()) .setPreserveAuthorizationOnRedirect(request.isPreserveAuthorizationOnRedirect()); }
if (request.getMethod().equals("DELETE")) { assertEquals(parts.size(), 1); return new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), new byte[0]);
if (request.getMethod().equals("DELETE")) { assertEquals(parts.size(), 1); return new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), new byte[0]);
if (request.getMethod().equals("DELETE")) { assertEquals(parts.size(), 1); return new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), new byte[0]);
@Override public Response handle(Request request) if (request.getMethod().equalsIgnoreCase("DELETE")) { return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]);
@Override public Response handle(Request request) if (request.getMethod().equalsIgnoreCase("DELETE")) { return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]);
throws Exception if (request.getMethod().equalsIgnoreCase("DELETE")) { return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.<String, String>of(), new byte[0]);
jettyRequest.method(finalRequest.getMethod());