private SdkHttpFullRequest mockSdkRequest(String uriString, SdkHttpMethod method) { URI uri = URI.create(uriString); SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder() .uri(uri) .method(method) .putHeader("Host", uri.getHost()) .putHeader("User-Agent", "hello-world!"); if (method != SdkHttpMethod.HEAD) { requestBuilder.contentStreamProvider(() -> new ByteArrayInputStream("Body".getBytes(StandardCharsets.UTF_8))); } return requestBuilder.build(); }
marshalledRequest.method(SdkHttpMethod.GET) .putRawQueryParameter(PARAM_DESTINATION_REGION, destinationRegion) .removeQueryParameter(PARAM_SOURCE_REGION)
marshalledRequest.method(SdkHttpMethod.GET) .putRawQueryParameter(PARAM_DESTINATION_REGION, destinationRegion) .removeQueryParameter(PARAM_SOURCE_REGION)
.toBuilder() .uri(endPointSource) .method(SdkHttpMethod.GET) .build();
.toBuilder() .uri(endPointSource) .method(SdkHttpMethod.GET) .build();
/** * Step 1 of the AWS Signature version 4 calculation. Refer to * http://docs.aws * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html to * generate the canonical request. */ private String createCanonicalRequest(SdkHttpFullRequest.Builder request, String contentSha256, boolean doubleUrlEncode) { String canonicalRequest = request.method().toString() + SignerConstant.LINE_SEPARATOR + // This would optionally double url-encode the resource path getCanonicalizedResourcePath(request.encodedPath(), doubleUrlEncode) + SignerConstant.LINE_SEPARATOR + getCanonicalizedQueryString(request.rawQueryParameters()) + SignerConstant.LINE_SEPARATOR + getCanonicalizedHeaderString(request.headers()) + SignerConstant.LINE_SEPARATOR + getSignedHeadersString(request.headers()) + SignerConstant.LINE_SEPARATOR + contentSha256; LOG.trace(() -> "AWS4 Canonical Request: " + canonicalRequest); return canonicalRequest; }
/** * Step 1 of the AWS Signature version 4 calculation. Refer to * http://docs.aws * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html to * generate the canonical request. */ private String createCanonicalRequest(SdkHttpFullRequest.Builder request, String contentSha256, boolean doubleUrlEncode) { String canonicalRequest = request.method().toString() + SignerConstant.LINE_SEPARATOR + // This would optionally double url-encode the resource path getCanonicalizedResourcePath(request.encodedPath(), doubleUrlEncode) + SignerConstant.LINE_SEPARATOR + getCanonicalizedQueryString(request.rawQueryParameters()) + SignerConstant.LINE_SEPARATOR + getCanonicalizedHeaderString(request.headers()) + SignerConstant.LINE_SEPARATOR + getSignedHeadersString(request.headers()) + SignerConstant.LINE_SEPARATOR + contentSha256; LOG.trace(() -> "AWS4 Canonical Request: " + canonicalRequest); return canonicalRequest; }
@Override public SdkHttpFullRequest.Builder toBuilder() { return new Builder() .contentStreamProvider(contentStreamProvider) .protocol(protocol) .host(host) .port(port) .encodedPath(path) .rawQueryParameters(queryParameters) .method(httpMethod) .headers(headers) ; }
/** * Creates the basic {@link SdkHttpFullRequest} with information from the {@link OperationInfo} and the endpoint. * * @param operationInfo Metadata about operation, contains HTTP method and request URI. * @param endpoint Endpoint of request. * @return Mutable {@link SdkHttpFullRequest.Builder} with HTTP method, URI, and static query parameters set. */ public static SdkHttpFullRequest.Builder createSdkHttpRequest(OperationInfo operationInfo, URI endpoint) { SdkHttpFullRequest.Builder request = SdkHttpFullRequest .builder() .method(operationInfo.httpMethod()) .uri(endpoint); return request.encodedPath(SdkHttpUtils.appendUri(request.encodedPath(), addStaticQueryParametersToRequest(request, operationInfo.requestUri()))); }
@Override public SdkHttpFullRequest.Builder toBuilder() { return new Builder() .contentStreamProvider(contentStreamProvider) .protocol(protocol) .host(host) .port(port) .encodedPath(path) .rawQueryParameters(queryParameters) .method(httpMethod) .headers(headers) ; }
private boolean shouldPutParamsInBody(SdkHttpFullRequest.Builder input) { return input.method() == SdkHttpMethod.POST && input.contentStreamProvider() == null && !CollectionUtils.isNullOrEmpty(input.rawQueryParameters()); }
/** * Creates the basic {@link SdkHttpFullRequest} with information from the {@link OperationInfo} and the endpoint. * * @param operationInfo Metadata about operation, contains HTTP method and request URI. * @param endpoint Endpoint of request. * @return Mutable {@link SdkHttpFullRequest.Builder} with HTTP method, URI, and static query parameters set. */ public static SdkHttpFullRequest.Builder createSdkHttpRequest(OperationInfo operationInfo, URI endpoint) { SdkHttpFullRequest.Builder request = SdkHttpFullRequest .builder() .method(operationInfo.httpMethod()) .uri(endpoint); return request.encodedPath(SdkHttpUtils.appendUri(request.encodedPath(), addStaticQueryParametersToRequest(request, operationInfo.requestUri()))); }