io.airlift.http.client.Request.builder()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(259)

本文整理了Java中io.airlift.http.client.Request.builder方法的一些代码示例,展示了Request.builder的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.builder方法的具体详情如下:
包路径:io.airlift.http.client.Request
类名称:Request
方法名:builder

Request.builder介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. class AuthInterceptor implements Interceptor {
  2. @Override public Response intercept(Chain chain) throws IOException {
  3. Request request = chain.request();
  4. String authHeader = // TODO get auth token
  5. request = request.builder()
  6. .header("Authorization", authHeader)
  7. .builder();
  8. return chain.proceed(request);
  9. }
  10. }

代码示例来源:origin: org.rakam/rakam-clickhouse

  1. public static StringResponseHandler.StringResponse runStatementSafe(ClickHouseConfig config, String query)
  2. {
  3. URI uri = UriBuilder
  4. .fromUri(config.getAddress()).queryParam("query", query).build();
  5. return HTTP_CLIENT.execute(Request.builder()
  6. .setUri(uri).setMethod("POST").build(),
  7. StringResponseHandler.createStringResponseHandler());
  8. }

代码示例来源:origin: org.rakam/rakam-clickhouse

  1. public ClickHouseQueryExecution(ClickHouseConfig config, String query)
  2. {
  3. this.query = query;
  4. this.queryId = UUID.randomUUID().toString();
  5. this.config = config;
  6. URI uri = UriBuilder
  7. .fromUri(config.getAddress())
  8. .queryParam("query_id", queryId).build();
  9. result = convertCompletableFuture(HTTP_CLIENT.executeAsync(
  10. Request.builder()
  11. .setUri(uri)
  12. .setMethod("POST")
  13. .setBodyGenerator(createStaticBodyGenerator(query + " format " + QueryResponseHandler.FORMAT, UTF_8))
  14. .build(),
  15. new QueryResponseHandler()));
  16. }

代码示例来源:origin: airlift/airlift

  1. private Request buildRequestWithQueryParam(String type, String override)
  2. {
  3. return Request.builder().setUri(server.getBaseUrl().resolve(format("/?_method=%s", override))).setMethod(type).build();
  4. }

代码示例来源:origin: org.rakam/rakam-clickhouse

  1. private void executeRequest(ProjectCollection collection, List<SchemaField> schema, List<Event> events, CompletableFuture<Void> future, boolean tried) {
  2. HttpResponseFuture<StringResponse> f = HTTP_CLIENT.executeAsync(Request.builder()
  3. .setUri(buildInsertUri(collection, schema))
  4. .setMethod("POST")
  5. .setBodyGenerator(new BinaryRawGenerator(events, schema))
  6. .build(), createStringResponseHandler());
  7. f.addListener(() -> {
  8. try {
  9. StringResponse stringResponse = f.get(1L, MINUTES);
  10. if (stringResponse.getStatusCode() == 200) {
  11. future.complete(null);
  12. }
  13. else {
  14. RuntimeException ex = new RuntimeException(stringResponse.getStatusMessage() + " : "
  15. + stringResponse.getBody().split("\n", 2)[0]);
  16. future.completeExceptionally(ex);
  17. }
  18. }
  19. catch (InterruptedException|ExecutionException|TimeoutException e) {
  20. if(!tried) {
  21. executeRequest(collection, schema, events, future, true);
  22. } else {
  23. future.completeExceptionally(e);
  24. LOGGER.error(e);
  25. }
  26. }
  27. }, Runnable::run);
  28. }

代码示例来源:origin: airlift/airlift

  1. private Request buildRequestWithHeader(String type, String override)
  2. {
  3. return Request.builder().setUri(server.getBaseUrl()).setMethod(type).addHeader("X-HTTP-Method-Override", override).build();
  4. }

相关文章