Class UtilHttp

java.lang.Object
eirb.pub.app.server.utils.UtilHttp

public class UtilHttp extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.hc.client5.http.async.methods.SimpleHttpResponse
    executeRequest(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest)
    Execute Http request synchronously with a timeout
    static CompletableFuture<org.apache.hc.client5.http.async.methods.SimpleHttpResponse>
    executeRequestAsync(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest)
     
    static CompletableFuture<org.apache.hc.client5.http.async.methods.SimpleHttpResponse>
    executeRequestAsync(org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient httpClient, org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest)
    Executes the given HTTP request asynchronously and returns a future representing the result.
    static org.json.JSONObject
    executeRequestJSON(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest)
    Execute Http request synchronously with a timeout
    static CompletableFuture<org.json.JSONObject>
    executeRequestJSONAsync(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest)
    Executes the given HTTP request asynchronously and returns a future representing the result in JSONFormat.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • executeRequestAsync

      public static CompletableFuture<org.apache.hc.client5.http.async.methods.SimpleHttpResponse> executeRequestAsync(org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient httpClient, org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest) throws IOException
      Executes the given HTTP request asynchronously and returns a future representing the result.

      The returned CompletableFuture will:

      Parameters:
      httpClient - The HTTP client to use.
      httpUriRequest - The HTTP request to execute.
      Returns:
      A CompletableFuture representing the asynchronous result of the request.
      Throws:
      IOException
    • executeRequestAsync

      public static CompletableFuture<org.apache.hc.client5.http.async.methods.SimpleHttpResponse> executeRequestAsync(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest) throws IOException
      Throws:
      IOException
    • executeRequestJSONAsync

      public static CompletableFuture<org.json.JSONObject> executeRequestJSONAsync(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest) throws IOException
      Executes the given HTTP request asynchronously and returns a future representing the result in JSONFormat.

      The returned CompletableFuture will:

      Parameters:
      httpUriRequest - The HTTP request to execute.
      Returns:
      A CompletableFuture representing the asynchronous result of the request.
      Throws:
      IOException
    • executeRequest

      public static org.apache.hc.client5.http.async.methods.SimpleHttpResponse executeRequest(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest) throws TimeoutException, ServerException, IOException
      Execute Http request synchronously with a timeout
      Parameters:
      httpUriRequest - request to execute
      Returns:
      the request response
      Throws:
      ServerException - can be 400, 401, 500 error from the server
      IOException - if the connection was interrupted
      TimeoutException - if the timeout was reached
    • executeRequestJSON

      public static org.json.JSONObject executeRequestJSON(org.apache.hc.client5.http.classic.methods.HttpUriRequest httpUriRequest) throws ServerException, IOException, TimeoutException
      Execute Http request synchronously with a timeout
      Parameters:
      httpUriRequest - request to execute
      Returns:
      the request response as JSON
      Throws:
      ServerException - can be 400, 401, 500 error from the server
      IOException - if the connection was interrupted
      TimeoutException - if the timeout was reached