Package com.styra.opa.openapi.utils
Class SpeakeasyHTTPClient
java.lang.Object
com.styra.opa.openapi.utils.SpeakeasyHTTPClient
- All Implemented Interfaces:
HTTPClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsend
(HttpRequest request) Sends an HTTP request and returns the response.static void
setDebugLogging
(boolean enabled) Experimental, may be changed anytime.static void
static void
setRedactedHeaders
(Collection<String> headerNames) Experimental, may be changed anytime.
-
Constructor Details
-
SpeakeasyHTTPClient
public SpeakeasyHTTPClient()
-
-
Method Details
-
setDebugLogging
public static void setDebugLogging(boolean enabled) Experimental, may be changed anytime. Sets debug logging on or off for requests and responses including bodies for JSON content. WARNING: this setting may expose sensitive information in logs (like Authorization headers), and should only be enabled temporarily for local debugging purposes. By default, Authorization headers are redacted in the logs ( printed with a value of[*******]
). Header suppression is controlled with thesetRedactedHeaders(Collection)
method.- Parameters:
enabled
- true to enable debug logging, false to disable it
-
setRedactedHeaders
Experimental, may be changed anytime. When debug logging is enabled this method controls the suppression of header values in the logs. By default, Authorization headers are redacted in the logs (printed with a value of[*******]
). Header suppression is controlled with thesetRedactedHeaders(Collection)
method.- Parameters:
headerNames
- the names (case-insensitive) of the headers whose values will be redacted in the logs
-
setLogger
-
send
public HttpResponse<InputStream> send(HttpRequest request) throws IOException, InterruptedException, URISyntaxException Description copied from interface:HTTPClient
Sends an HTTP request and returns the response.Note that
HttpRequest
is immutable. To modify the request you can useHttpRequest.newBuilder(HttpRequest, BiPredicate<String, String>)
with JDK 16 and later (which will copy the request for modification in a builder). If that method is not available then useHelpers.copy(java.net.http.HttpRequest)
(which also returns a builder).- Specified by:
send
in interfaceHTTPClient
- Parameters:
request
- HTTP request- Returns:
- HTTP response
- Throws:
IOException
InterruptedException
URISyntaxException
-