use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class WindowSizeTest method expectCorrectWindowSizeValueTest.
private void expectCorrectWindowSizeValueTest(Integer builderSetterValue, int settingsFrameValue) throws InterruptedException {
ConcurrentLinkedQueue<Http2Frame> receivedFrames = new ConcurrentLinkedQueue<>();
server = new TestH2Server(() -> new StreamHandler(receivedFrames));
server.init();
netty = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).http2Configuration(Http2Configuration.builder().initialWindowSize(builderSetterValue).build()).build();
AsyncExecuteRequest req = AsyncExecuteRequest.builder().requestContentPublisher(new EmptyPublisher()).request(SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).protocol("http").host("localhost").port(server.port()).build()).responseHandler(new SdkAsyncHttpResponseHandler() {
@Override
public void onHeaders(SdkHttpResponse headers) {
}
@Override
public void onStream(Publisher<ByteBuffer> stream) {
}
@Override
public void onError(Throwable error) {
}
}).build();
netty.execute(req).join();
List<Http2Settings> receivedSettings = receivedFrames.stream().filter(f -> f instanceof Http2SettingsFrame).map(f -> (Http2SettingsFrame) f).map(Http2SettingsFrame::settings).collect(Collectors.toList());
assertThat(receivedSettings.size()).isGreaterThan(0);
for (Http2Settings s : receivedSettings) {
assertThat(s.initialWindowSize()).isEqualTo(settingsFrameValue);
}
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class NettyClientTlsAuthTest method sendRequest.
private void sendRequest(SdkAsyncHttpClient client, SdkAsyncHttpResponseHandler responseHandler) {
AsyncExecuteRequest req = AsyncExecuteRequest.builder().request(testSdkRequest()).requestContentPublisher(new EmptyPublisher()).responseHandler(responseHandler).build();
client.execute(req).join();
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class NettyNioAsyncHttpClientSpiVerificationTest method callsOnStreamForEmptyResponseContent.
@Test
public void callsOnStreamForEmptyResponseContent() throws Exception {
stubFor(any(urlEqualTo("/")).willReturn(aResponse().withStatus(204).withHeader("foo", "bar")));
CompletableFuture<Boolean> streamReceived = new CompletableFuture<>();
SdkAsyncHttpResponseHandler handler = new TestResponseHandler() {
@Override
public void onStream(Publisher<ByteBuffer> stream) {
super.onStream(stream);
streamReceived.complete(true);
}
};
SdkHttpRequest request = createRequest(URI.create("http://localhost:" + mockServer.port()));
client.execute(AsyncExecuteRequest.builder().request(request).responseHandler(handler).requestContentPublisher(new EmptyPublisher()).build());
assertThat(streamReceived.get(1, TimeUnit.SECONDS)).isTrue();
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class ProxyWireMockTest method proxyConfigured_hostInNonProxySet_doesNotConnect.
@Test
public void proxyConfigured_hostInNonProxySet_doesNotConnect() {
RecordingResponseHandler responseHandler = new RecordingResponseHandler();
AsyncExecuteRequest req = AsyncExecuteRequest.builder().request(testSdkRequest()).responseHandler(responseHandler).requestContentPublisher(new EmptyPublisher()).build();
ProxyConfiguration cfg = proxyCfg.toBuilder().nonProxyHosts(Stream.of("localhost").collect(Collectors.toSet())).build();
client = NettyNioAsyncHttpClient.builder().proxyConfiguration(cfg).build();
client.execute(req).join();
responseHandler.completeFuture.join();
assertThat(responseHandler.fullResponseAsString()).isEqualTo("hello");
}
Aggregations