本文整理了Java中com.linecorp.armeria.common.HttpResponse.aggregate()
方法的一些代码示例,展示了HttpResponse.aggregate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.aggregate()
方法的具体详情如下:
包路径:com.linecorp.armeria.common.HttpResponse
类名称:HttpResponse
方法名:aggregate
[英]Aggregates this response. The returned CompletableFuture will be notified when the content and the trailing headers of the response are received fully.
[中]汇总这一回应。返回的CompletableFuture将在完全接收到响应的内容和尾部标题时得到通知。
代码示例来源:origin: line/armeria
@Override
public CompletableFuture<Boolean> isHealthy(Endpoint endpoint) {
return httpClient.get(healthCheckPath)
.aggregate()
.thenApply(message -> HttpStatus.OK.equals(message.status()));
}
}
代码示例来源:origin: line/armeria
@Test
public void hello() throws Exception {
final AggregatedHttpMessage res = client.get("/hello").aggregate().join();
assertThat(res.status()).isEqualTo(HttpStatus.OK);
assertThat(res.content().toStringUtf8()).isEqualTo("Hello, World");
}
代码示例来源:origin: line/armeria
@Test
public void success() {
final AggregatedHttpMessage response = client.get("/hello/Spring").aggregate().join();
assertThat(response.status()).isEqualTo(HttpStatus.OK);
assertThat(response.content().toStringUtf8())
.isEqualTo("Hello, Spring! This message is from Armeria annotated service!");
}
代码示例来源:origin: line/armeria
@Test
public void healthCheck() throws Exception {
final AggregatedHttpMessage res = client.get("/internal/healthcheck").aggregate().join();
assertThat(res.status()).isEqualTo(HttpStatus.OK);
assertThat(res.content().toStringUtf8()).isEqualTo("ok");
}
}
代码示例来源:origin: line/armeria
@Test
public void index() {
final AggregatedHttpMessage res = client.get("/").aggregate().join();
assertThat(res.status()).isEqualTo(HttpStatus.OK);
assertThat(res.content().toStringUtf8()).isEqualTo("index");
}
代码示例来源:origin: line/armeria
@Test
public void testAnnotatedServiceRegistrationBean() throws Exception {
final HttpClient client = HttpClient.of(newUrl("h1c"));
HttpResponse response = client.get("/annotated/get");
AggregatedHttpMessage msg = response.aggregate().get();
assertThat(msg.status()).isEqualTo(HttpStatus.OK);
assertThat(msg.content().toStringUtf8()).isEqualTo("annotated");
response = client.get("/annotated/get/2");
msg = response.aggregate().get();
assertThat(msg.status()).isEqualTo(HttpStatus.OK);
assertThat(msg.content().toStringUtf8()).isEqualTo("exception");
}
代码示例来源:origin: line/armeria
@Test
public void shouldGetHelloFromRestController() throws Exception {
protocols.forEach(scheme -> {
final HttpClient client = HttpClient.of(clientFactory, scheme + "://example.com:" + port);
final AggregatedHttpMessage response = client.get("/hello").aggregate().join();
assertThat(response.content().toStringUtf8()).isEqualTo("hello");
});
}
代码示例来源:origin: line/armeria
@Test
public void shouldGetHelloFromRestController() throws Exception {
final HttpClient client = HttpClient.of("http://127.0.0.1:" + port);
final AggregatedHttpMessage response = client.get("/proxy?port=" + port).aggregate().join();
assertThat(response.content().toStringUtf8()).isEqualTo("hello");
}
}
代码示例来源:origin: line/armeria
@Test
public void testHttpServiceRegistrationBean() throws Exception {
final HttpClient client = HttpClient.of(newUrl("h1c"));
final HttpResponse response = client.get("/ok");
final AggregatedHttpMessage msg = response.aggregate().get();
assertThat(msg.status()).isEqualTo(HttpStatus.OK);
assertThat(msg.content().toStringUtf8()).isEqualTo("ok");
}
}
代码示例来源:origin: line/armeria
@Test
public void withoutTracking() throws Exception {
final HttpClient client = HttpClient.of(rule.uri("/"));
assertThat(client.execute(HttpHeaders.of(HttpMethod.GET, "/foo")).aggregate().get().status())
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
}
代码示例来源:origin: line/armeria
private AggregatedHttpMessage sendPostRequest(HttpClient client) {
final HttpHeaders requestHeaders =
HttpHeaders.of(HttpMethod.POST, "/hello")
.add(HttpHeaderNames.USER_AGENT, "test-agent/1.0.0")
.add(HttpHeaderNames.ACCEPT_ENCODING, "gzip");
return client.execute(requestHeaders, HttpData.of(POST_BODY.getBytes())).aggregate().join();
}
代码示例来源:origin: line/armeria
private AggregatedHttpMessage sendViaHttpPostBindingProtocol(
String path, String paramName, SignableSAMLObject sinableObj) throws Exception {
final String encoded = toSignedBase64(sinableObj, idpCredential, signatureAlgorithm);
final QueryStringEncoder encoder = new QueryStringEncoder("/");
encoder.addParam(paramName, encoded);
final HttpRequest req = HttpRequest.of(HttpMethod.POST, path, MediaType.FORM_DATA,
encoder.toUri().getRawQuery());
return client.execute(req).aggregate().join();
}
代码示例来源:origin: line/armeria
private static AggregatedHttpMessage makeMetricsRequest() throws ExecutionException,
InterruptedException {
final HttpClient client = HttpClient.of("http://127.0.0.1:" + server.httpPort());
return client.execute(HttpHeaders.of(HttpMethod.GET, "/internal/prometheus/metrics")
.setObject(HttpHeaderNames.ACCEPT, MediaType.PLAIN_TEXT_UTF_8))
.aggregate().get();
}
代码示例来源:origin: line/armeria
@Test
public void failure() {
final AggregatedHttpMessage response = client.get("/hello/a").aggregate().join();
assertThat(response.status()).isEqualTo(HttpStatus.BAD_REQUEST);
assertThatJson(response.content().toStringUtf8())
.node("message")
.isEqualTo("hello.name: name should have between 3 and 10 characters");
}
}
代码示例来源:origin: line/armeria
@Test
public void enableTracking() throws Exception {
try {
RequestContextAssembly.enable();
final HttpClient client = HttpClient.of(rule.uri("/"));
assertThat(client.execute(HttpHeaders.of(HttpMethod.GET, "/foo")).aggregate().get().status())
.isEqualTo(HttpStatus.OK);
} finally {
RequestContextAssembly.disable();
}
}
代码示例来源:origin: line/armeria
@Test
public void testMetrics() throws Exception {
final String metricReport = HttpClient.of(newUrl("http"))
.get("/internal/metrics")
.aggregate().join()
.content().toStringUtf8();
assertThat(metricReport).contains("# TYPE jvm_gc_live_data_size_bytes gauge");
}
}
代码示例来源:origin: line/armeria
@Test
public void shouldReturnEchoResponse() {
final ArmeriaReactiveWebServerFactory factory = factory();
runEchoServer(factory, server -> {
final HttpClient client = httpClient(server);
validateEchoResponse(sendPostRequest(client));
final AggregatedHttpMessage res = client.get("/hello").aggregate().join();
assertThat(res.status()).isEqualTo(com.linecorp.armeria.common.HttpStatus.OK);
assertThat(res.content().toStringUtf8()).isEmpty();
});
}
代码示例来源:origin: line/armeria
@Test
public void testThriftServiceRegistrationBean() throws Exception {
final HelloService.Iface client = Clients.newClient(newUrl("tbinary+h1c") + "/thrift",
HelloService.Iface.class);
assertThat(client.hello("world")).isEqualTo("hello world");
final HttpClient httpClient = HttpClient.of(newUrl("h1c"));
final HttpResponse response = httpClient.get("/internal/docs/specification.json");
final AggregatedHttpMessage msg = response.aggregate().get();
assertThat(msg.status()).isEqualTo(HttpStatus.OK);
assertThatJson(msg.content().toStringUtf8())
.node("services[1].exampleHttpHeaders[0].x-additional-header").isStringEqualTo("headerVal");
}
代码示例来源:origin: line/armeria
@Test
public void unframed_grpcEncoding() throws Exception {
final HttpClient client = HttpClient.of(server.httpUri("/"));
final AggregatedHttpMessage response = client.execute(
HttpHeaders.of(HttpMethod.POST,
UnitTestServiceGrpc.getStaticUnaryCallMethod().getFullMethodName())
.set(HttpHeaderNames.CONTENT_TYPE, "application/protobuf")
.set(GrpcHeaderNames.GRPC_ENCODING, "gzip"),
REQUEST_MESSAGE.toByteArray()).aggregate().get();
assertThat(response.status()).isEqualTo(HttpStatus.UNSUPPORTED_MEDIA_TYPE);
assertNoRpcContent();
}
代码示例来源:origin: line/armeria
@Test
public void unframed_streamingApi() throws Exception {
final HttpClient client = HttpClient.of(server.httpUri("/"));
final AggregatedHttpMessage response = client.execute(
HttpHeaders.of(HttpMethod.POST,
UnitTestServiceGrpc.getStaticStreamedOutputCallMethod().getFullMethodName())
.set(HttpHeaderNames.CONTENT_TYPE, "application/protobuf"),
StreamingOutputCallRequest.getDefaultInstance().toByteArray()).aggregate().get();
assertThat(response.status()).isEqualTo(HttpStatus.BAD_REQUEST);
assertNoRpcContent();
}
内容来源于网络,如有侵权,请联系作者删除!