本文整理汇总了Java中io.vertx.core.http.HttpClient.getAbs方法的典型用法代码示例。如果您正苦于以下问题:Java HttpClient.getAbs方法的具体用法?Java HttpClient.getAbs怎么用?Java HttpClient.getAbs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpClient
的用法示例。
在下文中一共展示了HttpClient.getAbs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import io.vertx.core.http.HttpClient; //导入方法依赖的package包/类
private void send(String url, HttpMethod method, String content,
int errorCode, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
switch (method) {
case POST:
request = client.postAbs(url);
break;
case DELETE:
request = client.deleteAbs(url);
break;
case GET:
request = client.getAbs(url);
break;
default:
request = client.putAbs(url);
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
})
.handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", SUPPORTED_CONTENT_TYPE_JSON_DEF);
request.end(buffer);
}
示例2: send
import io.vertx.core.http.HttpClient; //导入方法依赖的package包/类
private void send(String url, HttpMethod method, String content,
String contentType, int errorCode, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if(content == null){
content = "";
}
Buffer buffer = Buffer.buffer(content);
if (method == HttpMethod.POST) {
request = client.postAbs(url);
}
else if (method == HttpMethod.DELETE) {
request = client.deleteAbs(url);
}
else if (method == HttpMethod.GET) {
request = client.getAbs(url);
}
else {
request = client.putAbs(url);
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
})
.handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", contentType);
request.end(buffer);
}