@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 308) { return false; } else { return super.shouldRetryRequest(command, response); } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 308) { return false; } else { return super.shouldRetryRequest(command, response); } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 308) { return false; } else { return super.shouldRetryRequest(command, response); } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (command.getCurrentRequest().getMethod().equals("DELETE")) { return false; } else { return super.shouldRetryRequest(command, response); } } }
@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); } }
@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); } }
@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); } }
@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); } }
@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); } }
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); } }
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 test302DoesNotRetry() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = HttpResponse.builder() .statusCode(302) .message("HTTP/1.1 302 Found").build(); expect(command.isReplayable()).andReturn(true); expect(command.incrementRedirectCount()).andReturn(0); replay(command); RedirectionRetryHandler retry = injector.getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }
@Test public void test302DoesNotRetryAfterLimit() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = HttpResponse.builder() .statusCode(302) .message("HTTP/1.1 302 Found") .addHeader(LOCATION, "/api/v0.8b-ext2.5/Error.aspx?aspxerrorpath=/api/v0.8b-ext2.5/org.svc/1906645").build(); expect(command.isReplayable()).andReturn(true); expect(command.incrementRedirectCount()).andReturn(6); replay(command); RedirectionRetryHandler retry = injector.getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }
@Test public void test302DoesNotRetry() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = HttpResponse.builder() .statusCode(302) .message("HTTP/1.1 302 Found").build(); expect(command.isReplayable()).andReturn(true); expect(command.incrementRedirectCount()).andReturn(0); replay(command); RedirectionRetryHandler retry = injector.getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }
@Test public void test302DoesNotRetryAfterLimit() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = HttpResponse.builder() .statusCode(302) .message("HTTP/1.1 302 Found") .addHeader(LOCATION, "/api/v0.8b-ext2.5/Error.aspx?aspxerrorpath=/api/v0.8b-ext2.5/org.svc/1906645").build(); expect(command.isReplayable()).andReturn(true); expect(command.incrementRedirectCount()).andReturn(6); replay(command); RedirectionRetryHandler retry = injector.getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); String host = error.getDetails().get("Endpoint"); if (host != null) { if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) { // must be an amazon error related to // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287𑩟 return backoffHandler.shouldRetryRequest(command, response); } else { URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build(); command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build()); } return true; } else { return false; } } else { return super.shouldRetryRequest(command, response); } } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); String host = error.getDetails().get("Endpoint"); if (host != null) { if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) { // must be an amazon error related to // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287𑩟 return backoffHandler.shouldRetryRequest(command, response); } else { URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build(); command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build()); } return true; } else { return false; } } else { return super.shouldRetryRequest(command, response); } } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); String host = error.getDetails().get("Endpoint"); if (host != null) { if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) { // must be an amazon error related to // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287𑩟 return backoffHandler.shouldRetryRequest(command, response); } else { URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build(); command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build()); } return true; } else { return false; } } else { return super.shouldRetryRequest(command, response); } } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); String host = error.getDetails().get("Endpoint"); if (host != null) { if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) { // must be an amazon error related to // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287𑩟 return backoffHandler.shouldRetryRequest(command, response); } else { URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build(); command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build()); } return true; } else { return false; } } else { return super.shouldRetryRequest(command, response); } } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); String host = error.getDetails().get("Endpoint"); if (host != null) { if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) { // must be an amazon error related to // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287𑩟 return backoffHandler.shouldRetryRequest(command, response); } else { URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build(); command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build()); } return true; } else { return false; } } else { return super.shouldRetryRequest(command, response); } } }