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); }
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
return true; } else { command.incrementRedirectCount(); closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getRequest(), 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); } } }
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
return false; if (command.incrementRedirectCount() > retryCountLimit) { logger.error("Cannot retry after redirect, command exceeded retry limit %d: %s", retryCountLimit, command); return false;
@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); } } }