Class HttpClient
java.lang.Object
HttpClient
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends GlobalpingResponse>
TsendRequest(GlobalpingRequest request, Class<T> cl) The only public method in this class sends a request and parses the response into expected class of type parameter.
-
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 extendGlobalpingResponse.- Parameters:
request- theGlobalpingRequestwith required information.cl- theClassobject 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.
-