Class HttpClient

  • Direct Known Subclasses:
    HttpURLConnectionClient

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

      • maxNetworkRetriesDelay

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

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

      • HttpClient

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

      • requestWithTelemetry

        public StripeResponse requestWithTelemetry​(StripeRequest request)
                                            throws StripeException
        Sends the given request to Stripe's API, handling telemetry if not disabled.
        Parameters:
        request - the request
        Returns:
        the response
        Throws:
        StripeException - If the request fails for any reason
      • 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
      • buildUserAgentString

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

        protected static java.lang.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