@Test public void testRegionHeaderIsAddedToExcpetion() throws XMLStreamException { String region = "myDummyRegion"; String strResponse = "<Error><Code>PermanentRedirect</Code><Message>The bucket is in this region: null. Please use this region to retry the request</Message></Error>"; ByteArrayInputStream content = new ByteArrayInputStream(strResponse.getBytes(Charset.forName("UTF-8"))); S3ErrorResponseHandler errorHandler = new S3ErrorResponseHandler(); Request request = new DefaultRequest("default"); request.setHttpMethod(HttpMethodName.GET); HttpResponse response = new HttpResponse(request, null); response.setContent(content); response.addHeader(Headers.S3_BUCKET_REGION, region); AmazonS3Exception exception = (AmazonS3Exception)errorHandler.handle(response); assertTrue(exception.getAdditionalDetails().get(Headers.S3_BUCKET_REGION).equals(region)); }
@Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; }
S3ErrorResponseHandler implements
        HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; } }
S3ErrorResponseHandler implements
        HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; }  }
S3ErrorResponseHandler implements
        HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; }  @Override AmazonServiceException handle(HttpResponse httpResponse); boolean needsConnectionLeftOpen(); }
S3ErrorResponseHandler implements
        HttpResponseHandler<AmazonServiceException> { @Override public AmazonServiceException handle(HttpResponse httpResponse) throws XMLStreamException { final AmazonServiceException exception = createException(httpResponse); exception.setHttpHeaders(httpResponse.getHeaders()); return exception; }  @Override AmazonServiceException handle(HttpResponse httpResponse); boolean needsConnectionLeftOpen();  }