本文整理了Java中io.airlift.http.client.Request.builder
方法的一些代码示例,展示了Request.builder
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.builder
方法的具体详情如下:
包路径:io.airlift.http.client.Request
类名称:Request
方法名:builder
暂无
代码示例来源:origin: stackoverflow.com
class AuthInterceptor implements Interceptor {
@Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
String authHeader = // TODO get auth token
request = request.builder()
.header("Authorization", authHeader)
.builder();
return chain.proceed(request);
}
}
代码示例来源:origin: org.rakam/rakam-clickhouse
public static StringResponseHandler.StringResponse runStatementSafe(ClickHouseConfig config, String query)
{
URI uri = UriBuilder
.fromUri(config.getAddress()).queryParam("query", query).build();
return HTTP_CLIENT.execute(Request.builder()
.setUri(uri).setMethod("POST").build(),
StringResponseHandler.createStringResponseHandler());
}
代码示例来源:origin: org.rakam/rakam-clickhouse
public ClickHouseQueryExecution(ClickHouseConfig config, String query)
{
this.query = query;
this.queryId = UUID.randomUUID().toString();
this.config = config;
URI uri = UriBuilder
.fromUri(config.getAddress())
.queryParam("query_id", queryId).build();
result = convertCompletableFuture(HTTP_CLIENT.executeAsync(
Request.builder()
.setUri(uri)
.setMethod("POST")
.setBodyGenerator(createStaticBodyGenerator(query + " format " + QueryResponseHandler.FORMAT, UTF_8))
.build(),
new QueryResponseHandler()));
}
代码示例来源:origin: airlift/airlift
private Request buildRequestWithQueryParam(String type, String override)
{
return Request.builder().setUri(server.getBaseUrl().resolve(format("/?_method=%s", override))).setMethod(type).build();
}
代码示例来源:origin: org.rakam/rakam-clickhouse
private void executeRequest(ProjectCollection collection, List<SchemaField> schema, List<Event> events, CompletableFuture<Void> future, boolean tried) {
HttpResponseFuture<StringResponse> f = HTTP_CLIENT.executeAsync(Request.builder()
.setUri(buildInsertUri(collection, schema))
.setMethod("POST")
.setBodyGenerator(new BinaryRawGenerator(events, schema))
.build(), createStringResponseHandler());
f.addListener(() -> {
try {
StringResponse stringResponse = f.get(1L, MINUTES);
if (stringResponse.getStatusCode() == 200) {
future.complete(null);
}
else {
RuntimeException ex = new RuntimeException(stringResponse.getStatusMessage() + " : "
+ stringResponse.getBody().split("\n", 2)[0]);
future.completeExceptionally(ex);
}
}
catch (InterruptedException|ExecutionException|TimeoutException e) {
if(!tried) {
executeRequest(collection, schema, events, future, true);
} else {
future.completeExceptionally(e);
LOGGER.error(e);
}
}
}, Runnable::run);
}
代码示例来源:origin: airlift/airlift
private Request buildRequestWithHeader(String type, String override)
{
return Request.builder().setUri(server.getBaseUrl()).setMethod(type).addHeader("X-HTTP-Method-Override", override).build();
}
内容来源于网络,如有侵权,请联系作者删除!