/** Returns the endpoint as a URI. */ private URI toURI(String endpoint) throws IllegalArgumentException { return RuntimeHttpUtils.toUri(endpoint, clientConfiguration); }
/** * Returns an URI for the given endpoint. * Prefixes the protocol if the endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) { // If the underlying AmazonS3Client has enabled accelerate mode and the original // request operation is accelerate mode supported, then the request will use the // s3-accelerate endpoint to performe the operations. if (clientOptions.isAccelerateModeEnabled() && !(originalRequest instanceof S3AccelerateUnsupported)) { if (clientOptions.isDualstackEnabled()) { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration); } else { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration); } } Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME); request.setHttpMethod(httpMethod); request.addHandlerContext(S3HandlerContextKeys.IS_CHUNKED_ENCODING_DISABLED, Boolean.valueOf(clientOptions.isChunkedEncodingDisabled())); request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED, Boolean.valueOf(clientOptions.isPayloadSigningEnabled())); resolveRequestEndpoint(request, bucketName, key, endpoint); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, SERVICE_ID); return request; }
/** * Specifically made package access for testing. * Used for internal consumption of AWS SDK. * * Tries to determine the service endpoint for the bucket name. * Returns the endpoint configured in the client if the region cannot be determined. */ URI resolveServiceEndpoint(String bucketName) { if (getSignerRegion() != null || isSignerOverridden()) return endpoint; final String regionStr = fetchRegionFromCache(bucketName); final com.amazonaws.regions.Region region = RegionUtils.getRegion(regionStr); if (region == null) { log.warn("Region information for " + regionStr + " is not available. Please upgrade to latest version of AWS Java SDK"); } return region != null ? RuntimeHttpUtils.toUri(region.getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration) : endpoint; }
/** Returns the endpoint as a URI. */ private URI toURI(String endpoint) throws IllegalArgumentException { return RuntimeHttpUtils.toUri(endpoint, clientConfiguration); }
resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration)); return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region); } else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
/** * Returns an URI for the given endpoint. * Prefixes the protocol if the endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
/** * @param endpoint the endpoint. * @param config the client configuration. * @return an URI for the given endpoint. Prefixes the protocol if the * endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) { final Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME); // If the underlying AmazonS3Client has enabled accelerate mode and the // original request operation is accelerate mode supported, then the request // will use the s3-accelerate endpoint to performs the operations. if (clientOptions.isAccelerateModeEnabled() && !(request.getOriginalRequest() instanceof S3AccelerateUnsupported)) { if (clientOptions.isDualstackEnabled()) { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration); } else { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration); } } request.setHttpMethod(httpMethod); resolveRequestEndpoint(request, bucketName, key, endpoint); return request; }
@Test public void testUri() throws MalformedURLException, URISyntaxException { Assert.assertEquals(new URI("https://demo.us-east-1.amazonaws.com/"), RuntimeHttpUtils.toUri("demo.us-east-1.amazonaws.com/", new ClientConfiguration().withProtocol(Protocol.HTTPS))); exception.expect(IllegalArgumentException.class); RuntimeHttpUtils.toUri(null, new ClientConfiguration()); exception.expect(IllegalArgumentException.class); RuntimeHttpUtils.toUri(null, (ClientConfiguration) null); Assert.assertEquals(new URI("http://demo.us-east-1.amazonaws.com/"), RuntimeHttpUtils.toUri("https://demo.us-east-1.amazonaws.com/", new ClientConfiguration().withProtocol(Protocol.HTTP))); }
/** Returns the endpoint as a URI. */ private URI toURI(String endpoint) throws IllegalArgumentException { return RuntimeHttpUtils.toUri(endpoint, clientConfiguration); }
resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri( RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));
/** * Returns an URI for the given endpoint. * Prefixes the protocol if the endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
/** * @param endpoint the endpoint. * @param config the client configuration. * @return an URI for the given endpoint. Prefixes the protocol if the * endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
/** * @param endpoint the endpoint. * @param config the client configuration. * @return an URI for the given endpoint. Prefixes the protocol if the * endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); }
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) { final Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME); // If the underlying AmazonS3Client has enabled accelerate mode and the // original request operation is accelerate mode supported, then the request // will use the s3-accelerate endpoint to performs the operations. if (clientOptions.isAccelerateModeEnabled() && !(request.getOriginalRequest() instanceof S3AccelerateUnsupported)) { if (clientOptions.isDualstackEnabled()) { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration); } else { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration); } } request.setHttpMethod(httpMethod); resolveRequestEndpoint(request, bucketName, key, endpoint); return request; }
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) { // If the underlying AmazonS3Client has enabled accelerate mode and the original // request operation is accelerate mode supported, then the request will use the // s3-accelerate endpoint to performe the operations. if (clientOptions.isAccelerateModeEnabled() && !(originalRequest instanceof S3AccelerateUnsupported)) { if (clientOptions.isDualstackEnabled()) { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration); } else { endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration); } } Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME); request.setHttpMethod(httpMethod); request.addHandlerContext(S3HandlerContextKeys.IS_CHUNKED_ENCODING_DISABLED, Boolean.valueOf(clientOptions.isChunkedEncodingDisabled())); request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED, Boolean.valueOf(clientOptions.isPayloadSigningEnabled())); resolveRequestEndpoint(request, bucketName, key, endpoint); return request; }
/** * Specifically made package access for testing. * Used for internal consumption of AWS SDK. * * Tries to determine the service endpoint for the bucket name. * Returns the endpoint configured in the client if the region cannot be determined. */ URI resolveServiceEndpoint(String bucketName) { if (getSignerRegion() != null || isSignerOverridden()) return endpoint; final String regionStr = fetchRegionFromCache(bucketName); final com.amazonaws.regions.Region region = RegionUtils.getRegion(regionStr); if (region == null) { log.warn("Region information for " + regionStr + " is not available. Please upgrade to latest version of AWS Java SDK"); } return region != null ? RuntimeHttpUtils.toUri(region.getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration) : endpoint; }
resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration)); return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region); } else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri( RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));