protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
private URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(host).build(); }
protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
@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); } } }
protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); URI newEndpoint = uriBuilder(request.getEndpoint()).host(name.toString()).build(); return (R) request.toBuilder().endpoint(newEndpoint).replacePath(request.getEndpoint().getRawPath()).build(); } }
public void testHost() { assertEquals(uriBuilder("https://foo.com:8080").host("robots").toString(), "https://robots:8080"); assertEquals(uriBuilder("https://foo.com:8080").host("robots").build().toString(), "https://robots:8080"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").build().toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").toString(), "https://robots/repos/{user}"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").build(templateParams) .toASCIIString(), "https://robots/repos/bob"); }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); URI newEndpoint = uriBuilder(request.getEndpoint()).host(name.toString()).build(); return (R) request.toBuilder().endpoint(newEndpoint).replacePath(request.getEndpoint().getRawPath()).build(); } }
private URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(host).build(); }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.toString()).build()).build(); } }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build(); } }
private URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(host).build(); }
protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); URI newEndpoint = uriBuilder(request.getEndpoint()).host(name.toString()).build(); return (R) request.toBuilder().endpoint(newEndpoint).replacePath(request.getEndpoint().getRawPath()).build(); } }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build(); } }
public void testHost() { assertEquals(uriBuilder("https://foo.com:8080").host("robots").toString(), "https://robots:8080"); assertEquals(uriBuilder("https://foo.com:8080").host("robots").build().toString(), "https://robots:8080"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").build().toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").toString(), "https://robots/repos/{user}"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").build(templateParams) .toASCIIString(), "https://robots/repos/bob"); }