Codota Logo
HttpResponse$BodyHandlers
Code IndexAdd Codota to your IDE (free)

How to use
HttpResponse$BodyHandlers
in
java.net.http

Best Java code snippets using java.net.http.HttpResponse$BodyHandlers (Showing top 5 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: com.playtika.reactivefeign/feign-reactor-java11

  private void upgradeToH2c(Target target){
    try {
      httpClient.send(HttpRequest.newBuilder()
          .method("options", HttpRequest.BodyPublishers.noBody())
          .uri(URI.create(target.url()))
          .build(),
          HttpResponse.BodyHandlers.discarding());
    } catch (IOException | InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
}
origin: svenkubiak/mangooio

      .send(this.httpRequest.build(), HttpResponse.BodyHandlers.ofString());
} catch (URISyntaxException | IOException | InterruptedException e) {
  LOG.error("Failed to execute HTTP request", e);
origin: net.dongliu/xhttp

/**
 * Build http request, and send out sync.
 */
public AsyncResponseContext sendAsync() {
  Request request = build();
  // interceptors
  var interceptors = Lists.convert(client.interceptors(), InterceptorSupplier::get);
  for (var interceptor : interceptors) {
    request = interceptor.onRequest(request);
  }
  var finalRequest = request;
  var httpRequest = RequestUtils.toHttpRequest(finalRequest);
  var responseFuture = client.httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofPublisher())
      .thenApply(r -> {
        var headers = Headers.ofHttpHeaders(r.headers());
        URL url;
        try {
          url = r.uri().toURL();
        } catch (MalformedURLException e) {
          throw new RequestsException(e);
        }
        return new SimpleAsyncResponseInfo(url, r.statusCode(), headers, r.body());
      });
  return new AsyncResponseContext(method, responseFuture, interceptors);
}
origin: com.playtika.reactivefeign/feign-reactor-java11

@Override
public Mono<ReactiveHttpResponse> executeRequest(ReactiveHttpRequest request) {
  HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(request.uri())
      .method(request.method().toUpperCase(), provideBody(request));
  setUpHeaders(request, requestBuilder);
  if(requestTimeout > 0){
    requestBuilder = requestBuilder.timeout(Duration.ofMillis(requestTimeout));
  }
  if(tryUseCompression){
    requestBuilder = requestBuilder.setHeader(ACCEPT_ENCODING_HEADER, GZIP);
  }
  Java11ReactiveHttpResponse.ReactiveBodySubscriber bodySubscriber = new Java11ReactiveHttpResponse.ReactiveBodySubscriber();
  CompletableFuture<HttpResponse<Void>> response = httpClient.sendAsync(
      requestBuilder.build(), fromSubscriber(bodySubscriber));
  return Mono.fromFuture(response)
      .<ReactiveHttpResponse>map(resp -> {
        if(!resp.version().equals(httpClient.version())){
          throw new IllegalArgumentException("Incorrect response version:"+resp.version());
        }
        return new Java11ReactiveHttpResponse(resp, bodySubscriber.content(),
            returnPublisherClass, returnActualClass,
            jsonFactory, responseReader);
      })
      .onErrorMap(ex -> ex instanceof CompletionException
               && ex.getCause() instanceof java.net.http.HttpTimeoutException,
          ReadTimeoutException::new);
}
origin: net.dongliu/xhttp

HttpResponse<InputStream> response;
try {
  response = client.httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofInputStream());
} catch (IOException e) {
  throw new UncheckedIOException(e);
java.net.httpHttpResponse$BodyHandlers

Most used methods

  • discarding
  • fromSubscriber
  • ofInputStream
  • ofPublisher
  • ofString

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now