Class InterceptResponse

java.lang.Object
io.karatelabs.driver.InterceptResponse

public class InterceptResponse extends Object
Represents a mock HTTP response for request interception.
  • Method Details

    • of

      public static InterceptResponse of(int status, Map<String,Object> headers, byte[] body)
      Create a response with the given status, headers, and body.
    • of

      public static InterceptResponse of(int status, byte[] body)
      Create a response with the given status and body.
    • of

      public static InterceptResponse of(int status, String body)
      Create a response with the given status and string body.
    • json

      public static InterceptResponse json(int status, Object body)
      Create a JSON response.
    • json

      public static InterceptResponse json(Object body)
      Create a JSON response with 200 OK status.
    • html

      public static InterceptResponse html(int status, String html)
      Create an HTML response.
    • html

      public static InterceptResponse html(String html)
      Create an HTML response with 200 OK status.
    • text

      public static InterceptResponse text(int status, String text)
      Create a text response.
    • text

      public static InterceptResponse text(String text)
      Create a text response with 200 OK status.
    • status

      public static InterceptResponse status(int status)
      Create an empty response with just a status code.
    • ok

      public static InterceptResponse ok()
      Create a 200 OK response.
    • notFound

      public static InterceptResponse notFound()
      Create a 404 Not Found response.
    • serverError

      public static InterceptResponse serverError()
      Create a 500 Internal Server Error response.
    • redirect

      public static InterceptResponse redirect(String location)
      Create a redirect response.
    • header

      public InterceptResponse header(String name, String value)
      Add a header to this response.
    • getStatus

      public int getStatus()
      Get the HTTP status code.
    • getHeaders

      public Map<String,Object> getHeaders()
      Get the response headers.
    • getBody

      public byte[] getBody()
      Get the response body as bytes.
    • getBodyBase64

      public String getBodyBase64()
      Get the response body as a Base64-encoded string.
    • getBodyString

      public String getBodyString()
      Get the response body as a string (UTF-8).