io.vertx.core.http.HttpClientRequest Java Examples

The following examples show how to use io.vertx.core.http.HttpClientRequest. 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: RESTServiceSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointEight_header() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointEight_header?val=123&tmp=456",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println(
                      "Got a createResponse endpointFourErrorReturnRetryTest: "
                          + body.toString());

                  assertEquals(body.toString(), "123456");
                });
            String contentType = resp.getHeader("Content-Type");
            assertEquals(contentType, "application/json");
            testComplete();
          });
  request.end();
  await();
}
 
Example #2
Source File: S3Client.java    From vertx-s3-client with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: RESTServiceSelfhostedTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
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",
          resp ->
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "test");
                    testComplete();
                  }));
  request.end();
  await();
}
 
Example #4
Source File: RESTServiceChainByteTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #5
Source File: RESTServiceBlockingChainStringTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestSupplyWithErrorSimpleRetry() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestSupplyWithErrorSimpleRetry",
          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 #6
Source File: RESTJerseyClientTimeoutTests.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleTimeoutTest_1() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleTimeoutTest",
          resp -> {
            resp.exceptionHandler(
                error -> {
                  System.out.println("Got a createResponse ERROR: " + error.toString());
                });
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  assertEquals(body.toString(), "operation _timeout");
                  testComplete();
                });
          });
  request.end();
  await();
}
 
Example #7
Source File: TofuSecurityTest.java    From orion with Apache License 2.0 6 votes vote down vote up
@Test
void testWithoutSSLConfiguration() {
  final CompletableAsyncResult<HttpClientResponse> result = AsyncResult.incomplete();
  final HttpClient insecureClient = vertx.createHttpClient(new HttpClientOptions().setSsl(true));

  final HttpClientRequest req = insecureClient.get(config.nodePort(), "localhost", "/upcheck");
  req.handler(result::complete).exceptionHandler(result::completeExceptionally).end();

  final CompletionException e = assertThrows(CompletionException.class, result::get);
  assertTrue(e.getCause() instanceof SSLHandshakeException);

  final HttpClientRequest clientRequest = insecureClient.get(config.clientPort(), "localhost", "/upcheck");
  clientRequest.handler(result::complete).exceptionHandler(result::completeExceptionally).end();

  final CompletionException clientException = assertThrows(CompletionException.class, result::get);
  assertTrue(clientException.getCause() instanceof SSLHandshakeException);
}
 
Example #8
Source File: RESTVerticleRouteBuilderSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointEight_header() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointEight_header?val=123&tmp=456",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println(
                      "Got a createResponse endpointFourErrorReturnRetryTest: "
                          + body.toString());

                  assertEquals(body.toString(), "123456");
                });
            String contentType = resp.getHeader("Content-Type");
            assertEquals(contentType, "application/json");
            testComplete();
          });
  request.end();
  await();
}
 
Example #9
Source File: RESTServiceSelfhostedAsyncTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void asyncStringResponse() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/asyncStringResponse",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  assertEquals(body.toString(), "test");
                  testComplete();
                });
          });
  request.end();
  await();
}
 
Example #10
Source File: RESTVerticleRouteBuilderSelfhostedTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFourErrorRetryTest() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFourErrorRetryTest?val=123&tmp=456",
          resp -> resp.bodyHandler(
              body -> {
                System.out.println("Got a createResponse: " + body.toString());
                assertEquals(body.toString(), "123456");
                testComplete();
              }));
  request.end();
  await();
}
 
Example #11
Source File: RESTVerticleRouteBuilderSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFourErrorRetryTest() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFourErrorRetryTest?val=123&tmp=456",
          resp -> resp.bodyHandler(
              body -> {
                System.out.println("Got a createResponse: " + body.toString());
                assertEquals(body.toString(), "123456");
                testComplete();
              }));
  request.end();
  await();
}
 
Example #12
Source File: RESTServiceBlockingChainByteTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #13
Source File: FormParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 6 votes vote down vote up
@Test()
public void testOkFormDataArrayCsv(TestContext context) {
    Async async = context.async();
    HttpClientRequest req = httpClient.post(TEST_PORT, TEST_HOST, "/formdata/array/csv");
    req.handler(response -> {
        response.bodyHandler(body -> {
            context.assertEquals(response.statusCode(), 200);
            context.assertEquals("[\"1\",\"2\",\"3\"]", body.toString());
            async.complete();
        });
    });

    // Construct form
    StringBuffer payload = new StringBuffer().append("array_formdata=").append(esc.escape("1,2,3"));
    req.putHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
    req.end(payload.toString());
}
 
Example #14
Source File: OkapiPerformance.java    From okapi with Apache License 2.0 6 votes vote down vote up
public void doLogin(TestContext context) {
  String doc = "{" + LS
          + "  \"tenant\" : \"t1\"," + LS
          + "  \"username\" : \"peter\"," + LS
          + "  \"password\" : \"peter-password\"" + LS
          + "}";
  HttpClientRequest req = HttpClientLegacy.post(httpClient, port, "localhost", "/authn/login", response -> {
    context.assertEquals(200, response.statusCode());
    String headers = response.headers().entries().toString();
    okapiToken = response.getHeader("X-Okapi-Token");
    response.endHandler(x -> {
      useItWithGet(context);
    });
  });
  req.putHeader("X-Okapi-Tenant", okapiTenant);
  req.end(doc);
}
 
Example #15
Source File: RESTAsyncThreadCheck.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void statefulTimeoutWithRetryTest_() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/statefulTimeoutWithRetryTest/crash",
          resp ->
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "operation _timeout");
                    testComplete();
                  }));
  request.end();
  await();
}
 
Example #16
Source File: DestroyContainer.java    From sfs with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<HttpClientResponse> call(Void aVoid) {
    return auth.toHttpAuthorization()
            .flatMap(new Func1<String, Observable<HttpClientResponse>>() {
                @Override
                public Observable<HttpClientResponse> call(String s) {
                    StringBuilder urlBuilder = new StringBuilder();
                    urlBuilder = urlBuilder.append("/openstackswift001/" + accountName + "/" + containerName + "?destroy=1");
                    ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture();
                    HttpClientRequest httpClientRequest =
                            httpClient.delete(urlBuilder.toString(), handler::complete)
                                    .exceptionHandler(handler::fail)
                                    .setTimeout(5000)
                                    .putHeader(AUTHORIZATION, s);
                    httpClientRequest.end();
                    return handler
                            .single();
                }
            });

}
 
Example #17
Source File: RESTServiceBlockingChainByteTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #18
Source File: VertxClientHttpConnector.java    From vertx-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<ClientHttpResponse> connect(org.springframework.http.HttpMethod method, URI uri,
    Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {

    logger.debug("Connecting to '{}' with '{}", uri, method);

    if (!uri.isAbsolute()) {
        return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
    }

    CompletableFuture<ClientHttpResponse> responseFuture = new CompletableFuture<>();
    HttpClient client = vertx.createHttpClient(clientOptions);
    HttpClientRequest request = client.requestAbs(HttpMethod.valueOf(method.name()), uri.toString())
        .exceptionHandler(responseFuture::completeExceptionally)
        .handler(response -> {
            Flux<DataBuffer> responseBody = responseToFlux(response)
                .doFinally(ignore -> client.close());

            responseFuture.complete(new VertxClientHttpResponse(response, responseBody));
        });

    return requestCallback.apply(new VertxClientHttpRequest(request, bufferConverter))
        .then(Mono.fromCompletionStage(responseFuture));
}
 
Example #19
Source File: RESTServiceBlockingChainObjectTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #20
Source File: RESTServiceBlockingChainByteTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #21
Source File: FormParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 6 votes vote down vote up
@Test()
public void testOkFormDataSimpleNotRequiredWithParam(TestContext context) {
    Async async = context.async();
    HttpClientRequest req = httpClient.post(TEST_PORT, TEST_HOST, "/formdata/simple/not/required");
    req.handler(response -> {
        response.bodyHandler(body -> {
            context.assertEquals(response.statusCode(), 200);
            context.assertEquals("toto", body.toString());
            async.complete();
        });
    });

    // Construct form
    StringBuffer payload = new StringBuffer().append("formDataNotRequired=").append(esc.escape("toto"));
    req.putHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
    req.end(payload.toString());
}
 
Example #22
Source File: RESTJerseyClientTimeoutTests.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleTimeoutNonBlockingTest_1() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleTimeoutNonBlockingTest",
          resp -> {
            resp.exceptionHandler(
                error -> {
                  System.out.println("Got a createResponse ERROR: " + error.toString());
                });
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  assertEquals(body.toString(), "failure");
                  testComplete();
                });
          });
  request.end();
  await();
}
 
Example #23
Source File: RefreshIndex.java    From sfs with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<Void> call(Void aVoid) {
    return auth.toHttpAuthorization()
            .flatMap(s -> {
                ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture();
                HttpClientRequest httpClientRequest =
                        httpClient.post("/admin/001/refresh_index", handler::complete)
                                .exceptionHandler(handler::fail)
                                .putHeader(AUTHORIZATION, s)
                                .setTimeout(10000);
                httpClientRequest.end();
                return handler
                        .flatMap(httpClientResponse ->
                                Defer.just(httpClientResponse)
                                        .flatMap(new HttpClientResponseBodyBuffer(HTTP_OK))
                                        .doOnNext(buffer -> {
                                            checkState(httpClientResponse.statusCode() == HTTP_OK);
                                            ;
                                        }))
                        .map(new ToVoid<>());
            });

}
 
Example #24
Source File: ServerRecordTest.java    From cava with Apache License 2.0 6 votes vote down vote up
@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 #25
Source File: RESTServiceSelfhostedTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFourErrorRetryTest() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFourErrorRetryTest?val=123&tmp=456",
          resp ->
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "123456");
                    testComplete();
                  }));
  request.end();
  await();
}
 
Example #26
Source File: RESTJerseyClientEventStringResponseTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void complexSyncResponseTest() throws InterruptedException {
  System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT2);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/complexSyncResponse",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse" + body.toString());

                  assertEquals(body.toString(), "hello1");
                });

            testComplete();
          });
  request.end();
  await();
}
 
Example #27
Source File: RESTServiceExceptionTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #28
Source File: RESTServiceBlockingChainObjectTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@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 #29
Source File: ProxyService.java    From okapi with Apache License 2.0 6 votes vote down vote up
private void proxyRequestLog(Iterator<ModuleInstance> it,
                             ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
                             List<HttpClientRequest> clientRequestList, ModuleInstance mi) {

  RoutingContext ctx = pc.getCtx();
  HttpClientRequest clientRequest = httpClient.requestAbs(ctx.request().method(),
      makeUrl(mi, ctx), res -> logger.debug("proxyRequestLog 2"));
  clientRequestList.add(clientRequest);
  clientRequest.setChunked(true);
  if (!it.hasNext()) {
    relayToResponse(ctx.response(), null, pc);
    copyHeaders(clientRequest, ctx, mi);
    proxyResponseImmediate(pc, stream, bcontent, clientRequestList);
  } else {
    copyHeaders(clientRequest, ctx, mi);
    proxyR(it, pc, stream, bcontent, clientRequestList);
  }
  log(pc, clientRequest);
}
 
Example #30
Source File: RESTJerseyClientErrorTests.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void stringGETResponseSyncAsync() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/stringGETResponseSyncAsync",
          resp ->
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    assertEquals("test-123", val);
                    testComplete();
                  }));
  request.end();

  await(10000, TimeUnit.MILLISECONDS);
}