本文整理了Java中com.linecorp.armeria.client.HttpClient.execute()
方法的一些代码示例,展示了HttpClient.execute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.execute()
方法的具体详情如下:
包路径:com.linecorp.armeria.client.HttpClient
类名称:HttpClient
方法名:execute
[英]Sends an empty HTTP request with the specified headers.
[中]发送带有指定标头的空HTTP请求。
代码示例来源:origin: line/armeria
/**
* Sends an HTTP OPTIONS request.
*/
default HttpResponse options(String path) {
return execute(HttpHeaders.of(HttpMethod.OPTIONS, path));
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP HEAD request.
*/
default HttpResponse head(String path) {
return execute(HttpHeaders.of(HttpMethod.HEAD, path));
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP PUT request with the specified content.
*/
default HttpResponse put(String path, HttpData content) {
return execute(HttpHeaders.of(HttpMethod.PUT, path), content);
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP request with the specified headers and content.
*/
default HttpResponse execute(HttpHeaders headers, HttpData content) {
return execute(AggregatedHttpMessage.of(headers, content));
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP POST request with the specified content.
*/
default HttpResponse post(String path, String content, Charset charset) {
return execute(HttpHeaders.of(HttpMethod.POST, path), content, charset);
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP PATCH request with the specified content.
*/
default HttpResponse patch(String path, byte[] content) {
return execute(HttpHeaders.of(HttpMethod.PATCH, path), content);
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP GET request.
*/
default HttpResponse get(String path) {
return execute(HttpHeaders.of(HttpMethod.GET, path));
}
代码示例来源:origin: line/armeria
/**
* Sends an empty HTTP request with the specified headers.
*/
default HttpResponse execute(HttpHeaders headers) {
return execute(AggregatedHttpMessage.of(headers));
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP PUT request with the specified content.
*/
default HttpResponse put(String path, byte[] content) {
return execute(HttpHeaders.of(HttpMethod.PUT, path), content);
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP TRACE request.
*/
default HttpResponse trace(String path) {
return execute(HttpHeaders.of(HttpMethod.TRACE, path));
}
}
代码示例来源:origin: line/armeria
/**
* Sends an HTTP PATCH request with the specified content.
*/
default HttpResponse patch(String path, String content) {
return execute(HttpHeaders.of(HttpMethod.PATCH, path), HttpData.ofUtf8(content));
}
代码示例来源:origin: line/armeria
@BeforeClass
public static void beforeClass() {
httpClient = mock(HttpClient.class);
when(httpClient.execute((HttpRequest) any())).thenReturn(HttpResponse.of(HttpStatus.OK));
}
代码示例来源:origin: line/armeria
@Test
public void shouldBeAlreadyAuthenticated() throws Exception {
final HttpHeaders req = HttpHeaders.of(HttpMethod.GET, "/redirect")
.add(HttpHeaderNames.COOKIE, "test=test");
final AggregatedHttpMessage resp = client.execute(req).aggregate().join();
assertThat(resp.status()).isEqualTo(HttpStatus.OK);
assertThat(resp.content().toStringUtf8()).isEqualTo("authenticated");
}
代码示例来源: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 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 unframed_noContentType() throws Exception {
final HttpClient client = HttpClient.of(server.httpUri("/"));
final AggregatedHttpMessage response = client.execute(
HttpHeaders.of(HttpMethod.POST,
UnitTestServiceGrpc.getStaticUnaryCallMethod().getFullMethodName()),
REQUEST_MESSAGE.toByteArray()).aggregate().get();
assertThat(response.status()).isEqualTo(HttpStatus.UNSUPPORTED_MEDIA_TYPE);
assertNoRpcContent();
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!