private Function<HttpResponse, ?> getTransformer(String commandName, HttpCommand command) { HttpRequest request = command.getCurrentRequest(); Function<HttpResponse, ?> transformer = transformerForRequest.apply(request); logger.trace("<< response from %s is parsed by %s", commandName, transformer.getClass().getSimpleName()); return transformer; }
private Function<HttpResponse, ?> getTransformer(String commandName, HttpCommand command) { HttpRequest request = command.getCurrentRequest(); Function<HttpResponse, ?> transformer = transformerForRequest.apply(request); logger.trace("<< response from %s is parsed by %s", commandName, transformer.getClass().getSimpleName()); return transformer; }
public HttpResponseException(HttpCommand command, HttpResponse response) { this(String.format("request: %s %sfailed with response: %s", command.getCurrentRequest().getRequestLine(), requestPayloadIfStringOrFormIfNotReturnEmptyString(command.getCurrentRequest()), response.getStatusLine()), command, response); }
public VCloudResponseException(HttpCommand command, HttpResponse response, VCloudError error, Throwable cause) { super(String.format("request %1$s failed with error: %2$s", command.getCurrentRequest().getRequestLine(), error .toString()), command, response, cause); this.setError(error); }
@Override public ListenableFuture<HttpResponse> submit(HttpCommand command) { HttpRequest request = command.getCurrentRequest(); checkRequestHasContentLengthOrChunkedEncoding(request, "if the request has a payload, it must be set to chunked encoding or specify a content length: " + request); return ioExecutor.submit(new HttpResponseCallable(command)); }
private org.jclouds.Fallback<?> getFallback(String commandName, Invocation invocation, HttpCommand command) { HttpRequest request = command.getCurrentRequest(); org.jclouds.Fallback<?> fallback = config.getFallback(invocation); if (fallback instanceof InvocationContext) InvocationContext.class.cast(fallback).setContext(request); logger.trace("<< exceptions from %s are parsed by %s", commandName, fallback.getClass().getSimpleName()); return fallback; }
private org.jclouds.Fallback<?> getFallback(String commandName, Invocation invocation, HttpCommand command) { HttpRequest request = command.getCurrentRequest(); org.jclouds.Fallback<?> fallback = config.getFallback(invocation); if (fallback instanceof InvocationContext) InvocationContext.class.cast(fallback).setContext(request); logger.trace("<< exceptions from %s are parsed by %s", commandName, fallback.getClass().getSimpleName()); return fallback; }
public AWSResponseException(HttpCommand command, HttpResponse response, AWSError error) { super(String.format("request %s failed with code %s, error: %s", command.getCurrentRequest().getRequestLine(), response .getStatusCode(), error.toString()), command, response); this.setError(error); }
public AtmosResponseException(HttpCommand command, HttpResponse response, AtmosError error) { super(String.format("command %s failed with code %s, error: %s", command.getCurrentRequest() .getRequestLine(), response.getStatusCode(), error.toString()), command, response); this.setError(error); }
public AtmosResponseException(HttpCommand command, HttpResponse response, AtmosError error, Throwable cause) { super(String.format("command %1$s failed with error: %2$s", command.getCurrentRequest() .getRequestLine(), error.toString()), command, response, cause); this.setError(error); }
public AWSResponseException(HttpCommand command, HttpResponse response, AWSError error, Throwable cause) { super(String.format("request %1$s failed with error: %2$s", command.getCurrentRequest().getRequestLine(), error .toString()), command, response, cause); this.setError(error); }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { String location = response.getFirstHeaderOrNull(LOCATION); if (location != null && location.indexOf("Job") != -1) { HttpRequest getRequest = command.getCurrentRequest().toBuilder() .method(GET) .payload((Payload) null).build(); command.setCurrentRequest(getRequest); } return super.shouldRetryRequest(command, response); } }
public AtmosError parseAtmosErrorFromContent(HttpCommand command, HttpResponse response, InputStream content) throws HttpException { AtmosError error = factory.create(errorHandlerProvider.get()).parse(content); if (error.getCode() == 1032) { error.setStringSigned(signer.createStringToSign(command.getCurrentRequest())); } return error; }
protected void verifyRedirectRoutes(HttpRequest request, HttpResponse response, HttpRequest expected) { HttpCommand command = createMock(HttpCommand.class); expect(command.isReplayable()).andReturn(true); expect(command.incrementRedirectCount()).andReturn(0); expect(command.getCurrentRequest()).andReturn(request); command.setCurrentRequest(expected); replay(command); RedirectionRetryHandler retry = injector.getInstance(RedirectionRetryHandler.class); assert retry.shouldRetryRequest(command, response); verify(command); } }
@Test public void testParseAWSErrorFromContentHttpCommandHttpResponseInputStream() { AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response(getClass() .getResourceAsStream("/error.xml"))); assertEquals(error.getCode(), "NoSuchKey"); assertEquals(error.getMessage(), "The resource you requested does not exist"); assertEquals(error.getRequestToken(), "requesttoken"); assertEquals(error.getRequestId(), "4442587FB7D0A2F9"); assertEquals(error.getDetails().get("Resource"), "/mybucket/myfoto.jpg"); }
/** * HEAD requests don't have a payload */ @Test public void testNoExceptionWhenNoPayload() { HttpResponse response = HttpResponse.builder().statusCode(BAD_REQUEST.getStatusCode()).build(); assertNull(utils.parseAWSErrorFromContent(command.getCurrentRequest(), response)); }
@Override public HttpResponse invoke(HttpCommand command) { assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://howdyboys/client/1/foo HTTP/1.1"); return HttpResponse.builder().build(); }
@Override public HttpResponse invoke(HttpCommand command) { assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://localhost:9999/client/1/foo HTTP/1.1"); return HttpResponse.builder().build(); }
@Override public HttpResponse invoke(HttpCommand command) { assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://howdyboys/client/1/foo HTTP/1.1"); return HttpResponse.builder().build(); }
/** * clones or proxies can mess up the error message. */ @Test public void testNoExceptionParsingTextPlain() { HttpResponse response = HttpResponse.builder().statusCode(BAD_REQUEST.getStatusCode()).payload("foo bar").build(); response.getPayload().getContentMetadata().setContentType(TEXT_PLAIN); assertNull(utils.parseAWSErrorFromContent(command.getCurrentRequest(), response)); }