Search in sources :

Example 1 with HttpRequest

use of com.algolia.search.models.HttpRequest in project algoliasearch-client-java-2 by algolia.

the class JavaNetHttpRequester method buildRequest.

/**
 * Builds an http request from an AlgoliaRequest object
 *
 * @param algoliaRequest The Algolia request object
 */
private java.net.http.HttpRequest buildRequest(@Nonnull HttpRequest algoliaRequest) {
    java.net.http.HttpRequest.Builder builder = java.net.http.HttpRequest.newBuilder();
    buildHeaders(builder, algoliaRequest.getHeaders());
    buildURI(builder, algoliaRequest.getUri());
    builder.timeout(Duration.ofMillis(algoliaRequest.getTimeout()));
    BodyPublisher body = buildRequestBody(builder, algoliaRequest);
    builder.method(algoliaRequest.getMethod().toString(), body);
    return builder.build();
}
Also used : HttpRequest(com.algolia.search.models.HttpRequest) BodyPublisher(java.net.http.HttpRequest.BodyPublisher) Builder(java.net.http.HttpRequest.Builder)

Aggregations

HttpRequest (com.algolia.search.models.HttpRequest)1 BodyPublisher (java.net.http.HttpRequest.BodyPublisher)1 Builder (java.net.http.HttpRequest.Builder)1