Class HttpClient

java.lang.Object
HttpClient

public class HttpClient extends Object
This class represents an object which manages raw HTTP connection. It does not hold any values but contains critical methods to manage HTTP connection, request and responses.
  • Constructor Details

    • HttpClient

      public HttpClient()
  • Method Details

    • sendRequest

      public <T extends GlobalpingResponse> T sendRequest(GlobalpingRequest request, Class<T> cl) throws IOException, GlobalpingApiError
      The only public method in this class sends a request and parses the response into expected class of type parameter.

      Example Usage:

      
          HttpClient client = new HttpClient();
          CreateMeasurementResponse res = client.sendRequest(req, CreateMeasurementResponse.class);
       
       
      Type Parameters:
      T - the type of the response, which must extend GlobalpingResponse.
      Parameters:
      request - the GlobalpingRequest with required information.
      cl - the Class object representing the type of response expected.
      Returns:
      an instance of the response type T, deserialized from the API response.
      Throws:
      IOException - if there is an error on underlying connection.
      GlobalpingApiError - if there is an error on the Globalping service.