Package io.karatelabs.driver
Class InterceptResponse
java.lang.Object
io.karatelabs.driver.InterceptResponse
Represents a mock HTTP response for request interception.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBody()Get the response body as bytes.Get the response body as a Base64-encoded string.Get the response body as a string (UTF-8).Get the response headers.intGet the HTTP status code.Add a header to this response.static InterceptResponseCreate an HTML response.static InterceptResponseCreate an HTML response with 200 OK status.static InterceptResponseCreate a JSON response.static InterceptResponseCreate a JSON response with 200 OK status.static InterceptResponsenotFound()Create a 404 Not Found response.static InterceptResponseof(int status, byte[] body) Create a response with the given status and body.static InterceptResponseCreate a response with the given status and string body.static InterceptResponseCreate a response with the given status, headers, and body.static InterceptResponseok()Create a 200 OK response.static InterceptResponseCreate a redirect response.static InterceptResponseCreate a 500 Internal Server Error response.static InterceptResponsestatus(int status) Create an empty response with just a status code.static InterceptResponseCreate a text response.static InterceptResponseCreate a text response with 200 OK status.
-
Method Details
-
of
Create a response with the given status, headers, and body. -
of
Create a response with the given status and body. -
of
Create a response with the given status and string body. -
json
Create a JSON response. -
json
Create a JSON response with 200 OK status. -
html
Create an HTML response. -
html
Create an HTML response with 200 OK status. -
text
Create a text response. -
text
Create a text response with 200 OK status. -
status
Create an empty response with just a status code. -
ok
Create a 200 OK response. -
notFound
Create a 404 Not Found response. -
serverError
Create a 500 Internal Server Error response. -
redirect
Create a redirect response. -
header
Add a header to this response. -
getStatus
public int getStatus()Get the HTTP status code. -
getHeaders
Get the response headers. -
getBody
public byte[] getBody()Get the response body as bytes. -
getBodyBase64
Get the response body as a Base64-encoded string. -
getBodyString
Get the response body as a string (UTF-8).
-