use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class ConnectionReaperTest method makeRequest.
private void makeRequest(SdkAsyncHttpClient client) {
stubFor(WireMock.any(anyUrl()).willReturn(aResponse().withBody(randomAlphabetic(10))));
RecordingResponseHandler handler = new RecordingResponseHandler();
URI uri = URI.create("http://localhost:" + mockServer.port());
client.execute(AsyncExecuteRequest.builder().request(SdkHttpRequest.builder().uri(uri).method(SdkHttpMethod.GET).encodedPath("/").putHeader("Host", uri.getHost()).putHeader("Content-Length", "0").build()).requestContentPublisher(new EmptyPublisher()).responseHandler(handler).build()).join();
assertThat(handler.fullResponseAsString()).hasSize(10);
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class Http2MetricsTest method createExecuteRequest.
private AsyncExecuteRequest createExecuteRequest(MetricCollector metricCollector) {
URI uri = URI.create("http://localhost:" + SERVER.port());
SdkHttpRequest request = createRequest(uri);
return AsyncExecuteRequest.builder().request(request).requestContentPublisher(new EmptyPublisher()).responseHandler(new RecordingResponseHandler()).metricCollector(metricCollector).build();
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class NettyNioAsyncHttpClientSpiVerificationTest method signalsErrorViaOnErrorAndFuture.
// CONNECTION_RESET_BY_PEER does not work on JDK 11. See https://github.com/tomakehurst/wiremock/issues/1009
@Test
public void signalsErrorViaOnErrorAndFuture() throws Exception {
stubFor(any(urlEqualTo("/")).willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE)));
CompletableFuture<Boolean> errorSignaled = new CompletableFuture<>();
SdkAsyncHttpResponseHandler handler = new TestResponseHandler() {
@Override
public void onError(Throwable error) {
errorSignaled.complete(true);
}
};
SdkHttpRequest request = createRequest(URI.create("http://localhost:" + mockServer.port()));
CompletableFuture<Void> executeFuture = client.execute(AsyncExecuteRequest.builder().request(request).responseHandler(handler).requestContentPublisher(new EmptyPublisher()).build());
assertThat(errorSignaled.get(1, TimeUnit.SECONDS)).isTrue();
assertThatThrownBy(executeFuture::join).hasCauseInstanceOf(IOException.class);
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class PingTimeoutTest method makeRequest.
private CompletableFuture<Void> makeRequest(Duration healthCheckPingPeriod) {
netty = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).http2Configuration(Http2Configuration.builder().healthCheckPingPeriod(healthCheckPingPeriod).build()).build();
SdkHttpFullRequest request = SdkHttpFullRequest.builder().protocol("http").host("localhost").port(server.port()).method(SdkHttpMethod.GET).build();
AsyncExecuteRequest executeRequest = AsyncExecuteRequest.builder().fullDuplex(false).request(request).requestContentPublisher(new EmptyPublisher()).responseHandler(new SdkAsyncHttpResponseHandler() {
@Override
public void onHeaders(SdkHttpResponse headers) {
}
@Override
public void onStream(Publisher<ByteBuffer> stream) {
stream.subscribe(new Subscriber<ByteBuffer>() {
@Override
public void onSubscribe(Subscription s) {
s.request(Integer.MAX_VALUE);
}
@Override
public void onNext(ByteBuffer byteBuffer) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
});
}
@Override
public void onError(Throwable error) {
}
}).build();
return netty.execute(executeRequest);
}
use of software.amazon.awssdk.http.EmptyPublisher in project aws-sdk-java-v2 by aws.
the class WindowSizeTest method execute_noExplicitValueSet_sendsDefaultValueInSettings.
@Test
public void execute_noExplicitValueSet_sendsDefaultValueInSettings() throws InterruptedException {
ConcurrentLinkedQueue<Http2Frame> receivedFrames = new ConcurrentLinkedQueue<>();
server = new TestH2Server(() -> new StreamHandler(receivedFrames));
server.init();
netty = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).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(DEFAULT_INIT_WINDOW_SIZE);
}
}
Aggregations