Class HttpClient

java.lang.Object
com.stripe.net.HttpClient
Direct Known Subclasses:
HttpURLConnectionClient

public abstract class HttpClient extends Object
Base abstract class for HTTP clients used to send requests to Stripe's API.
  • Field Details

    • maxNetworkRetriesDelay

      public static final Duration maxNetworkRetriesDelay
      Maximum sleep time between tries to send HTTP requests after network failure.
    • minNetworkRetriesDelay

      public static final Duration minNetworkRetriesDelay
      Minimum sleep time between tries to send HTTP requests after network failure.
  • Constructor Details

    • HttpClient

      protected HttpClient()
      Initializes a new instance of the HttpClient class.
  • Method Details

    • request

      public abstract StripeResponse request(StripeRequest request) throws StripeException
      Sends the given request to Stripe's API, buffering the response body into memory.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • requestStream

      public StripeResponseStream requestStream(StripeRequest request) throws StripeException
      Sends the given request to Stripe's API, streaming the response body.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • requestWithTelemetry

      @Deprecated public StripeResponse requestWithTelemetry(StripeRequest request) throws StripeException
      Deprecated.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • requestStreamWithTelemetry

      @Deprecated public StripeResponseStream requestStreamWithTelemetry(StripeRequest request) throws StripeException
      Deprecated.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • sendWithRetries

      public <T extends com.stripe.net.AbstractStripeResponse<?>> T sendWithRetries(StripeRequest request, com.stripe.net.HttpClient.RequestSendFunction<T> send) throws StripeException
      Throws:
      StripeException
    • requestWithRetries

      public StripeResponse requestWithRetries(StripeRequest request) throws StripeException
      Sends the given request to Stripe's API, retrying the request in cases of intermittent problems.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • requestStreamWithRetries

      public StripeResponseStream requestStreamWithRetries(StripeRequest request) throws StripeException
      Sends the given request to Stripe's API, streaming the response, retrying the request in cases of intermittent problems.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      StripeException - If the request fails for any reason
    • buildUserAgentString

      protected static String buildUserAgentString()
      Builds the value of the User-Agent header.
      Returns:
      a string containing the value of the User-Agent header
    • buildXStripeClientUserAgentString

      protected static String buildXStripeClientUserAgentString()
      Builds the value of the X-Stripe-Client-User-Agent header.
      Returns:
      a string containing the value of the X-Stripe-Client-User-Agent header