Package com.stripe.net
Class HttpClient
- java.lang.Object
-
- com.stripe.net.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 Summary
Fields Modifier and Type Field Description static java.time.Duration
maxNetworkRetriesDelay
Maximum sleep time between tries to send HTTP requests after network failure.static java.time.Duration
minNetworkRetriesDelay
Minimum sleep time between tries to send HTTP requests after network failure.
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpClient()
Initializes a new instance of theHttpClient
class.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
buildUserAgentString()
Builds the value of theUser-Agent
header.protected static java.lang.String
buildXStripeClientUserAgentString()
Builds the value of theX-Stripe-Client-User-Agent
header.abstract StripeResponse
request(StripeRequest request)
Sends the given request to Stripe's API.StripeResponse
requestWithRetries(StripeRequest request)
Sends the given request to Stripe's API, retrying the request in cases of intermittent problems.StripeResponse
requestWithTelemetry(StripeRequest request)
Sends the given request to Stripe's API, handling telemetry if not disabled.
-
-
-
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 theHttpClient
class.
-
-
Method Detail
-
request
public abstract StripeResponse request(StripeRequest request) throws StripeException
Sends the given request to Stripe's API.- Parameters:
request
- the request- Returns:
- the response
- Throws:
StripeException
- If the request fails for any reason
-
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 theUser-Agent
header.- Returns:
- a string containing the value of the
User-Agent
header
-
buildXStripeClientUserAgentString
protected static java.lang.String buildXStripeClientUserAgentString()
Builds the value of theX-Stripe-Client-User-Agent
header.- Returns:
- a string containing the value of the
X-Stripe-Client-User-Agent
header
-
-