use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.
the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_overriddenOnClient.
@Test
public void singleHeader_inMarshalledRequest_overriddenOnClient() throws Exception {
SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().build());
requestBuilder.putHeader(singleHeaderName, "marshaller");
Map<String, List<String>> clientHeaders = new HashMap<>();
clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
stage.execute(requestBuilder, ctx);
assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("client");
}
use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.
the class MergeCustomHeadersStageTest method singleHeader_inRequestAsList_keepsMultipleValues.
@Test
public void singleHeader_inRequestAsList_keepsMultipleValues() throws Exception {
SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
requestBuilder.putHeader(singleHeaderName, "marshaller");
RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, Arrays.asList("request", "request2", "request3")).build()).build());
Map<String, List<String>> clientHeaders = new HashMap<>();
HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
stage.execute(requestBuilder, ctx);
assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request", "request2", "request3");
}
use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.
the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_overriddenOnRequest.
@Test
public void singleHeader_inMarshalledRequest_overriddenOnRequest() throws Exception {
SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
requestBuilder.putHeader(singleHeaderName, "marshaller");
RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, Collections.emptyMap()).build()).build();
MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
stage.execute(requestBuilder, ctx);
assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.
the class MergeCustomHeadersStageTest method singleHeader_inClient_overriddenOnRequest.
@Test
public void singleHeader_inClient_overriddenOnRequest() throws Exception {
SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
Map<String, List<String>> clientHeaders = new HashMap<>();
clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
stage.execute(requestBuilder, ctx);
assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.
the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_inClient_inRequest.
@Test
public void singleHeader_inMarshalledRequest_inClient_inRequest() throws Exception {
SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
requestBuilder.putHeader(singleHeaderName, "marshaller");
RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
Map<String, List<String>> clientHeaders = new HashMap<>();
clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
stage.execute(requestBuilder, ctx);
assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
Aggregations