Class HttpClientSubmitter

java.lang.Object
io.github.projectunified.faststats.httpclient.HttpClientSubmitter
All Implemented Interfaces:
Submitter

public class HttpClientSubmitter extends Object implements Submitter
Implementation of Submitter that uses HttpClient to submit GZIP-compressed telemetry payloads.
  • Constructor Details

    • HttpClientSubmitter

      public HttpClientSubmitter(String token)
      Constructs a new HttpClientSubmitter with standard HttpClient.
      Parameters:
      token - the authorization token (bearer)
    • HttpClientSubmitter

      public HttpClientSubmitter(java.net.http.HttpClient httpClient, String token)
      Constructs a new HttpClientSubmitter with standard HttpClient.
      Parameters:
      httpClient - the HttpClient instance to use
      token - the authorization token (bearer)
    • HttpClientSubmitter

      public HttpClientSubmitter(java.net.http.HttpClient httpClient, String baseUrl, String token, String userAgent)
      Constructs a new HttpClientSubmitter.
      Parameters:
      httpClient - the HttpClient instance to use
      baseUrl - the base URL
      token - the authorization token (bearer)
      userAgent - the user agent header value
  • Method Details

    • execute

      public Submitter.Response execute(String path, String json, boolean compressed) throws Exception
      Description copied from interface: Submitter
      Executes the HTTP request and returns the response context.
      Specified by:
      execute in interface Submitter
      Parameters:
      path - the target path or URL
      json - the JSON payload
      compressed - whether to compress the payload using GZIP
      Returns:
      the response context
      Throws:
      Exception - if a non-recoverable error occurs