io.vertx.core.http.HttpClientResponse Java Examples
The following examples show how to use
io.vertx.core.http.HttpClientResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RESTServiceChainByteTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestSupplyWithErrorUnhandled() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestSupplyWithErrorUnhandled", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { assertEquals(resp.statusCode(), 500); assertEquals(resp.statusMessage(), "test error"); testComplete(); } }); request.end(); await(); }
Example #2
Source File: ContainerPermissionsHeadContainerTest.java From sfs with Apache License 2.0 | 6 votes |
@Test public void testHeadContainerImplicitAllow(TestContext context) { runOnServerContext(context, () -> { Producer authNonAdmin0 = httpBasic("user", "user"); return just((Void) null) .flatMap(new PostAccount(httpClient(), accountName, authAdmin)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_NO_CONTENT)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new PutContainer(httpClient(), accountName, containerName, authNonAdmin0)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_CREATED)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new HeadContainer(httpClient(), accountName, containerName, authNonAdmin0)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_NO_CONTENT)) .map(new ToVoid<HttpClientResponse>()); }); }
Example #3
Source File: RESTServiceBlockingChainStringTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestSupplyWithError() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestSupplyWithError", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { System.out.println("Got a createResponse: " + body.toString()); assertEquals(body.toString(), "error test error"); testComplete(); }); } }); request.end(); await(); }
Example #4
Source File: ServerCaOrRecordTest.java From incubator-tuweni with Apache License 2.0 | 6 votes |
@Test void shouldReplaceFingerprint() throws Exception { HttpClientRequest req = fooClient.get(httpServer.actualPort(), "localhost", "/upcheck"); CompletableFuture<HttpClientResponse> respFuture = new CompletableFuture<>(); req.handler(respFuture::complete).exceptionHandler(respFuture::completeExceptionally).end(); HttpClientResponse resp = respFuture.join(); assertEquals(200, resp.statusCode()); List<String> knownClients = Files.readAllLines(knownClientsFile); assertEquals(3, knownClients.size(), String.join("\n", knownClients)); assertEquals("#First line", knownClients.get(0)); assertEquals("foobar.com " + DUMMY_FINGERPRINT, knownClients.get(1)); assertEquals("foo.com " + fooFingerprint, knownClients.get(2)); req = foobarClient.get(httpServer.actualPort(), "localhost", "/upcheck"); respFuture = new CompletableFuture<>(); req.handler(respFuture::complete).exceptionHandler(respFuture::completeExceptionally).end(); resp = respFuture.join(); assertEquals(200, resp.statusCode()); knownClients = Files.readAllLines(knownClientsFile); assertEquals(3, knownClients.size(), String.join("\n", knownClients)); assertEquals("#First line", knownClients.get(0)); assertEquals("foobar.com " + foobarFingerprint, knownClients.get(1)); assertEquals("foo.com " + fooFingerprint, knownClients.get(2)); }
Example #5
Source File: TestServiceRegistryClientImpl.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Test public void undateMicroserviceInstanceStatus_response_failure() { HttpClientResponse httpClientResponse = new MockUp<HttpClientResponse>() { @Mock int statusCode() { return 400; } }.getMockInstance(); new MockUp<RestClientUtil>() { @Mock void put(IpPort ipPort, String uri, RequestParam requestParam, Handler<RestResponse> responseHandler) { Holder<HttpClientResponse> holder = Deencapsulation.getField(responseHandler, "arg$4"); holder.value = httpClientResponse; } }; boolean result = oClient.undateMicroserviceInstanceStatus("svcId", "instanceId", "UP"); Assert.assertFalse(result); }
Example #6
Source File: RESTServiceExceptionTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void catchedAsyncStringErrorDelay() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/catchedAsyncStringErrorDelay?val=123&tmp=456", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------catchedAsyncStringErrorDelay: " + val); // assertEquals(key, "val"); testComplete(); }); } }); request.end(); await(5000, TimeUnit.MILLISECONDS); }
Example #7
Source File: RESTServiceExceptionTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void catchedAsyncByteErrorDelay() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/catchedAsyncByteErrorDelay?val=123&tmp=456", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------catchedAsyncByteErrorDelay: " + val); // assertEquals(key, "val"); testComplete(); }); } }); request.end(); await(5000, TimeUnit.MILLISECONDS); }
Example #8
Source File: RESTServiceChainByteTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void endpointOne() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/endpointOne", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { System.out.println("Got a createResponse: " + body.toString()); assertEquals(body.toString(), "1test final"); testComplete(); }); } }); request.end(); await(); }
Example #9
Source File: S3Client.java From vertx-s3-client with Apache License 2.0 | 6 votes |
private S3ClientRequest createPutAclRequest(String bucket, String key, Optional<AclHeadersRequest> aclHeadersRequest, Handler<HttpClientResponse> handler) { HttpClientRequest httpRequest = client.put("/" + bucket + "/" + key + "?acl", handler); final S3ClientRequest s3ClientRequest = new S3ClientRequest( "PUT", awsRegion, awsServiceName, httpRequest, awsAccessKey, awsSecretKey, clock, signPayload ) .setTimeout(globalTimeout) .putHeader(Headers.HOST, hostname); aclHeadersRequest.ifPresent(e -> s3ClientRequest.headers().addAll(populateAclHeadersRequest(e))); return s3ClientRequest; }
Example #10
Source File: S3Client.java From vertx-s3-client with Apache License 2.0 | 6 votes |
private S3ClientRequest createPutRequest(String bucket, String key, PutObjectRequest putObjectRequest, Handler<HttpClientResponse> handler) { HttpClientRequest httpRequest = client.put("/" + bucket + "/" + key, handler); final S3ClientRequest s3ClientRequest = new S3ClientRequest( "PUT", awsRegion, awsServiceName, httpRequest, awsAccessKey, awsSecretKey, clock, signPayload ) .setTimeout(globalTimeout) .putHeader(Headers.HOST, hostname); s3ClientRequest.headers().addAll(populatePutObjectHeaders(putObjectRequest)); s3ClientRequest.headers().addAll(populateAclHeadersRequest(putObjectRequest)); return s3ClientRequest; }
Example #11
Source File: PutObject.java From sfs with Apache License 2.0 | 6 votes |
@Override public Observable<HttpClientResponse> call(Void aVoid) { return auth.toHttpAuthorization() .flatMap(new Func1<String, Observable<HttpClientResponse>>() { @Override public Observable<HttpClientResponse> call(String s) { ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture(); HttpClientRequest httpClientRequest = httpClient.put("/openstackswift001/" + accountName + "/" + containerName + "/" + objectName, handler::complete) .exceptionHandler(handler::fail) .setTimeout(20000) .putHeader(AUTHORIZATION, s); for (String entry : headers.keySet()) { httpClientRequest = httpClientRequest.putHeader(entry, headers.get(entry)); } httpClientRequest.setChunked(isChunked()); httpClientRequest.end(buffer(data)); return handler .single(); } }); }
Example #12
Source File: RESTServiceBlockingChainObjectTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestSupplyWithErrorUnhandled() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestSupplyWithErrorUnhandled", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { assertEquals(resp.statusCode(), 500); assertEquals(resp.statusMessage(), "test error"); testComplete(); } }); request.end(); await(); }
Example #13
Source File: RESTServiceChainStringTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestSupplyWithError() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestSupplyWithError", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { System.out.println("Got a createResponse: " + body.toString()); assertEquals(body.toString(), "error test error"); testComplete(); }); } }); request.end(); await(); }
Example #14
Source File: ContainerPermissionsWithoutTest.java From sfs with Apache License 2.0 | 6 votes |
@Test public void testHeadContainerAsNonAdmin(TestContext context) { runOnServerContext(context, () -> { return just((Void) null) .flatMap(new PostAccount(httpClient(), accountName, authAdmin)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_NO_CONTENT)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new PutContainer(httpClient(), accountName, containerName, authAdmin)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_CREATED)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new HeadContainer(httpClient(), accountName, containerName, authWithoutPerms)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_FORBIDDEN)) .map(new ToVoid<HttpClientResponse>()); }); }
Example #15
Source File: PostAccount.java From sfs with Apache License 2.0 | 6 votes |
@Override public Observable<HttpClientResponse> call(Void aVoid) { return auth.toHttpAuthorization() .flatMap(new Func1<String, Observable<HttpClientResponse>>() { @Override public Observable<HttpClientResponse> call(String s) { ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture(); HttpClientRequest httpClientRequest = httpClient.post("/openstackswift001/" + accountName, handler::complete) .exceptionHandler(handler::fail) .setTimeout(10000) .putHeader(AUTHORIZATION, s); for (String entry : headers.keySet()) { httpClientRequest = httpClientRequest.putHeader(entry, headers.get(entry)); } httpClientRequest.end(); return handler .single(); } }); }
Example #16
Source File: HeadAccount.java From sfs with Apache License 2.0 | 6 votes |
@Override public Observable<HttpClientResponse> call(Void aVoid) { return auth.toHttpAuthorization() .flatMap(new Func1<String, Observable<HttpClientResponse>>() { @Override public Observable<HttpClientResponse> call(String s) { ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture(); httpClient.head("/openstackswift001/" + accountName, handler::complete) .exceptionHandler(handler::fail) .setTimeout(10000) .putHeader(AUTHORIZATION, s) .end(); return handler .single(); } }); }
Example #17
Source File: RESTServiceBlockingChainStringTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestAndThenWithErrorUnhandledRetry() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestAndThenWithErrorUnhandledRetry", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { System.out.println("Got a createResponse: " + body.toString()); assertEquals(body.toString(), "error 4 test error"); testComplete(); }); } }); request.end(); await(); }
Example #18
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 6 votes |
/** * Creates a resource using an HTTP POST request. * * @param uri The URI to post to. * @param body The body to post (may be {@code null}). * @param requestHeaders The headers to include in the request (may be {@code null}). * @param successPredicate A predicate on the HTTP response for determining success. * @return A future that will succeed if the predicate evaluates to {@code true}. * @throws NullPointerException if URI or predicate are {@code null}. */ public Future<MultiMap> create( final String uri, final Buffer body, final MultiMap requestHeaders, final Predicate<HttpClientResponse> successPredicate) { Objects.requireNonNull(uri); Objects.requireNonNull(successPredicate); return create( createRequestOptions().setURI(uri), body, requestHeaders, successPredicate, false); }
Example #19
Source File: RESTServiceExceptionTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void exceptionInMethodBody() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/exceptionInMethodBody?val=123&tmp=456", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------exceptionInMethodBody: " + val); // assertEquals(key, "val"); testComplete(); }); } }); request.end(); await(); }
Example #20
Source File: RESTServiceExceptionTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void exceptionInAsyncStringResponse() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/exceptionInAsyncStringResponse?val=123&tmp=456", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------exceptionInStringResponse: " + val); // assertEquals(key, "val"); testComplete(); }); } }); request.end(); await(5000, TimeUnit.MILLISECONDS); }
Example #21
Source File: S3Client.java From vertx-s3-client with Apache License 2.0 | 6 votes |
private S3ClientRequest createGetBucketRequest(String bucket, GetBucketRequest getBucketRequest, Handler<HttpClientResponse> handler) { final HttpClientRequest httpRequest = client.get(UrlEncodingUtils.addParamsSortedToUrl("/" + bucket, populateGetBucketQueryParams(getBucketRequest)), handler); final S3ClientRequest s3ClientRequest = new S3ClientRequest( "GET", awsRegion, awsServiceName, httpRequest, awsAccessKey, awsSecretKey, clock, signPayload ) .setTimeout(globalTimeout) .putHeader(Headers.HOST, hostname); return s3ClientRequest; }
Example #22
Source File: S3Client.java From vertx-s3-client with Apache License 2.0 | 6 votes |
private S3ClientRequest createHeadRequest(String bucket, String key, HeadObjectRequest headObjectRequest, Handler<HttpClientResponse> handler) { final HttpClientRequest httpRequest = client.head("/" + bucket + "/" + key, handler); final S3ClientRequest s3ClientRequest = new S3ClientRequest( "HEAD", awsRegion, awsServiceName, httpRequest, awsAccessKey, awsSecretKey, clock, signPayload ) .setTimeout(globalTimeout) .putHeader(Headers.HOST, hostname); s3ClientRequest.headers().addAll(populateHeadObjectHeaders(headObjectRequest)); return s3ClientRequest; }
Example #23
Source File: RESTServiceChainByteTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestAndThenWithErrorUnhandled() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestAndThenWithErrorUnhandled", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { assertEquals(resp.statusCode(), 500); assertEquals(resp.statusMessage(), "test error"); testComplete(); } }); request.end(); await(); }
Example #24
Source File: RESTServiceOnFailureTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void simpleOnFailureResponseBlocking() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/simpleOnFailureResponseBlocking", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------catchedAsyncByteErrorDelay: " + val); assertEquals("", val); testComplete(); }); } }); request.end(); await(10000, TimeUnit.MILLISECONDS); }
Example #25
Source File: RESTServiceBlockingChainByteTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestSupplyWithErrorUnhandled() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestSupplyWithErrorUnhandled", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { assertEquals(resp.statusCode(), 500); assertEquals(resp.statusMessage(), "test error"); testComplete(); } }); request.end(); await(); }
Example #26
Source File: RESTServiceBlockingChainObjectTest.java From vxms with Apache License 2.0 | 6 votes |
@Test // @Ignore public void basicTestAndThenWithErrorUnhandled() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/basicTestAndThenWithErrorUnhandled", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { assertEquals(resp.statusCode(), 500); assertEquals(resp.statusMessage(), "test error"); testComplete(); } }); request.end(); await(); }
Example #27
Source File: CreateUpdateDeleteObjectTest.java From sfs with Apache License 2.0 | 6 votes |
@Test public void testExpireTtl(TestContext context) { runOnServerContext(context, () -> { final byte[] data0 = "HELLO0".getBytes(UTF_8); final long currentTimeInMillis = currentTimeMillis(); return prepareContainer(context) // put an object then get/head the object .flatMap(new PutObject(httpClient(), accountName, containerName, objectName, authNonAdmin, data0) .setHeader(X_DELETE_AT, valueOf(currentTimeInMillis))) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_CREATED)) .map(new AssertObjectHeaders(context, data0, 0, false, 0, 0)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new GetObject(httpClient(), accountName, containerName, objectName, authNonAdmin)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_NOT_FOUND)) .map(new ToVoid<HttpClientResponse>()) .flatMap(new HeadObject(httpClient(), accountName, containerName, objectName, authNonAdmin)) .map(new HttpClientResponseHeaderLogger()) .map(new AssertHttpClientResponseStatusCode(context, HTTP_NOT_FOUND)) .map(new ToVoid<HttpClientResponse>()); }); }
Example #28
Source File: RESTServiceExceptionFallbackTest.java From vxms with Apache License 2.0 | 6 votes |
@Test public void exceptionInStringResponseWithErrorHandler() throws InterruptedException { HttpClientOptions options = new HttpClientOptions(); options.setDefaultPort(PORT); options.setDefaultHost(HOST); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get( "/wsService/exceptionInStringResponseWithErrorHandler?val=123&tmp=456", new Handler<HttpClientResponse>() { public void handle(HttpClientResponse resp) { resp.bodyHandler( body -> { String val = body.getString(0, body.length()); System.out.println("--------exceptionInStringResponse: " + val); // assertEquals(key, "val"); testComplete(); }); } }); request.end(); await(5000, TimeUnit.MILLISECONDS); }
Example #29
Source File: GetContainer.java From sfs with Apache License 2.0 | 5 votes |
@Override public Observable<HttpClientResponse> call(Void aVoid) { return auth.toHttpAuthorization() .flatMap(new Func1<String, Observable<HttpClientResponse>>() { @Override public Observable<HttpClientResponse> call(String s) { final Escaper escaper = urlFormParameterEscaper(); Iterable<String> keyValues = from(queryParams.entries()) .transform(input -> escaper.escape(input.getKey()) + '=' + escaper.escape(input.getValue())); String query = on('&').join(keyValues); ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture(); HttpClientRequest httpClientRequest = httpClient.get("/openstackswift001/" + accountName + "/" + containerName + (query.length() > 0 ? "?" + query : ""), handler::complete) .exceptionHandler(handler::fail) .setTimeout(20000) .putHeader(AUTHORIZATION, s); for (String entry : headerParams.keySet()) { httpClientRequest = httpClientRequest.putHeader(entry, headerParams.get(entry)); } httpClientRequest.end(); return handler .single(); } }); }
Example #30
Source File: CircuitBreakerExamples.java From vertx-circuit-breaker with Apache License 2.0 | 5 votes |
public void example3(Vertx vertx) { CircuitBreaker breaker = CircuitBreaker.create("my-circuit-breaker", vertx, new CircuitBreakerOptions().setMaxFailures(5).setTimeout(2000) ); // --- // Store the circuit breaker in a field and access it as follows // --- breaker.executeWithFallback( promise -> { vertx.createHttpClient().get(8080, "localhost", "/", ar -> { if (ar.succeeded()) { HttpClientResponse response = ar.result(); if (response.statusCode() != 200) { promise.fail("HTTP error"); } else { response .exceptionHandler(promise::fail) .bodyHandler(buffer -> { promise.complete(buffer.toString()); }); } } else { promise.fail("Connect error"); } }); }, v -> { // Executed when the circuit is opened return "Hello"; }) .onComplete(ar -> { // Do something with the result }); }