Interface HTTPClient
-
- All Known Implementing Classes:
RecordingClient,SpeakeasyHTTPClient
public interface HTTPClient
-
-
Field Summary
Fields Modifier and Type Field Description static java.net.http.HttpClientclient
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidenableDebugLogging(boolean enabled)Controls the debug flag that can be used by clients to perform conditional debugging actions like logging HTTP requests and responses.default booleanisDebugLoggingEnabled()Returns whether debug logging is enabled.default java.net.http.HttpResponse<java.io.InputStream>send(java.net.http.HttpRequest request)Sends an HTTP request and returns the response.
-
-
-
Method Detail
-
send
default java.net.http.HttpResponse<java.io.InputStream> send(java.net.http.HttpRequest request) throws java.io.IOException, java.lang.InterruptedException, java.net.URISyntaxExceptionSends an HTTP request and returns the response.Note that
HttpRequestis 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).- Parameters:
request- HTTP request- Returns:
- HTTP response
- Throws:
java.io.IOExceptionjava.lang.InterruptedExceptionjava.net.URISyntaxException
-
enableDebugLogging
default void enableDebugLogging(boolean enabled)
Controls the debug flag that can be used by clients to perform conditional debugging actions like logging HTTP requests and responses. This is currently implemented in SpeakeasyHTTPClient but custom client implementations are free to use this method similarly if they wish.- Parameters:
enabled- Whether to enable debug flag
-
isDebugLoggingEnabled
default boolean isDebugLoggingEnabled()
Returns whether debug logging is enabled.- Returns:
- Whether debug logging is enabled
-
-