use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class CrtHttpRequestConverter method requestToCrt.
public HttpRequest requestToCrt(SdkHttpFullRequest inputRequest) {
String method = inputRequest.method().name();
String encodedPath = encodedPathToCrtFormat(inputRequest.encodedPath());
String encodedQueryString = SdkHttpUtils.encodeAndFlattenQueryParameters(inputRequest.rawQueryParameters()).map(value -> "?" + value).orElse("");
HttpHeader[] crtHeaderArray = createHttpHeaderArray(inputRequest);
Optional<ContentStreamProvider> contentProvider = inputRequest.contentStreamProvider();
HttpRequestBodyStream crtInputStream = null;
if (contentProvider.isPresent()) {
crtInputStream = new CrtHttpRequestConverter.CrtInputStream(contentProvider.get());
}
return new HttpRequest(method, encodedPath + encodedQueryString, crtHeaderArray, crtInputStream);
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class AwsCrtV4aSignerTest method hostHeaderIncludesNonStandardPorts.
@Test
public void hostHeaderIncludesNonStandardPorts() {
SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
SdkHttpFullRequest request = testCase.requestBuilder.protocol("http").port(443).build();
SdkHttpFullRequest signed = v4aSigner.sign(request, executionAttributes);
assertThat(signed.firstMatchingHeader("Host")).hasValue("demo.us-east-1.amazonaws.com:443");
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class QueryParametersToBodyInterceptorTest method nonPostRequestsUnaltered.
private void nonPostRequestsUnaltered(SdkHttpMethod method) {
SdkHttpFullRequest request = requestBuilder.method(method).build();
SdkHttpFullRequest output = (SdkHttpFullRequest) interceptor.modifyHttpRequest(new HttpRequestOnlyContext(request, null), executionAttributes);
assertThat(output.rawQueryParameters()).hasSize(1);
assertThat(output.headers()).hasSize(0);
assertThat(output.contentStreamProvider()).isEmpty();
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class QueryParametersToBodyInterceptorTest method onlyAlterRequestsIfParamsArePresent.
@Test
public void onlyAlterRequestsIfParamsArePresent() throws Exception {
SdkHttpFullRequest request = requestBuilder.clearQueryParameters().build();
SdkHttpFullRequest output = (SdkHttpFullRequest) interceptor.modifyHttpRequest(new HttpRequestOnlyContext(request, null), executionAttributes);
assertThat(output.rawQueryParameters()).hasSize(0);
assertThat(output.headers()).hasSize(0);
assertThat(output.contentStreamProvider()).isEmpty();
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class AsyncStreamingRequestMarshallerTest method transferEncodingIsUsed_OverHttp1.
@Test
public void transferEncodingIsUsed_OverHttp1() {
when(requestBody.contentLength()).thenReturn(Optional.empty());
AsyncStreamingRequestMarshaller marshaller = createMarshaller(false, true, false);
SdkHttpFullRequest httpFullRequest = marshaller.marshall(object);
assertThat(httpFullRequest.firstMatchingHeader(Header.CONTENT_LENGTH)).isEmpty();
assertThat(httpFullRequest.firstMatchingHeader(Header.TRANSFER_ENCODING)).isPresent();
}
Aggregations