Class SpeakeasyHTTPClient

java.lang.Object
com.styra.opa.openapi.utils.SpeakeasyHTTPClient
All Implemented Interfaces:
HTTPClient

public class SpeakeasyHTTPClient extends Object implements HTTPClient
  • 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 the setRedactedHeaders(Collection) method.
      Parameters:
      enabled - true to enable debug logging, false to disable it
    • setRedactedHeaders

      public static void setRedactedHeaders(Collection<String> headerNames)
      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 the setRedactedHeaders(Collection) method.
      Parameters:
      headerNames - the names (case-insensitive) of the headers whose values will be redacted in the logs
    • setLogger

      public static void setLogger(Consumer<? super String> logger)
    • send

      Description copied from interface: HTTPClient
      Sends an HTTP request and returns the response.

      Note that HttpRequest is immutable. To modify the request you can use HttpRequest.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 use Helpers.copy(java.net.http.HttpRequest) (which also returns a builder).

      Specified by:
      send in interface HTTPClient
      Parameters:
      request - HTTP request
      Returns:
      HTTP response
      Throws:
      IOException
      InterruptedException
      URISyntaxException