|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.model.Action
org.mockserver.model.HttpResponse
public class HttpResponse
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.mockserver.model.Action |
|---|
Action.Type |
| Field Summary |
|---|
| Fields inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString |
|---|
logger |
| Constructor Summary | |
|---|---|
HttpResponse()
|
|
| Method Summary | |
|---|---|
HttpResponse |
applyDelay()
|
Body |
getBody()
|
String |
getBodyAsString()
|
ConnectionOptions |
getConnectionOptions()
|
List<Cookie> |
getCookies()
|
Delay |
getDelay()
|
String |
getFirstHeader(String name)
|
List<String> |
getHeader(String name)
|
List<Header> |
getHeaders()
|
Integer |
getStatusCode()
|
Action.Type |
getType()
|
static HttpResponse |
notFoundResponse()
|
static HttpResponse |
response()
|
static HttpResponse |
response(String body)
|
HttpResponse |
shallowClone()
|
HttpResponse |
updateHeader(Header header)
Update header to return as a Header object, if a header with the same name already exists it will be modified |
HttpResponse |
updateHeader(String name,
String... values)
Update header to return as a Header object, if a header with the same name already exists it will be modified |
HttpResponse |
withBody(Body body)
Set the body to return for example: string body: - exact(" |
HttpResponse |
withBody(byte[] body)
Set response body to return as binary such as a pdf or image |
HttpResponse |
withBody(String body)
Set response body to return as a string response body. |
HttpResponse |
withBody(String body,
Charset charset)
Set response body to return a string response body with the specified encoding. |
HttpResponse |
withConnectionOptions(ConnectionOptions connectionOptions)
The connection options for override the default connection behaviour, this allows full control of headers such as "Connection" or "Content-Length" or controlling whether the socket is closed after the response has been sent |
HttpResponse |
withCookie(Cookie cookie)
Add cookie to return as Set-Cookie header |
HttpResponse |
withCookie(String name,
String value)
Add cookie to return as Set-Cookie header |
HttpResponse |
withCookies(Cookie... cookies)
The cookies to return as Set-Cookie headers as a varargs of Cookie objects |
HttpResponse |
withCookies(List<Cookie> cookies)
The cookies to return as Set-Cookie headers as a list of Cookie objects |
HttpResponse |
withDelay(Delay delay)
The delay before responding with this request as a Delay object, for example new Delay(TimeUnit.SECONDS, 3) |
HttpResponse |
withDelay(TimeUnit timeUnit,
long value)
The delay before responding with this request as a Delay object, for example new Delay(TimeUnit.SECONDS, 3) |
HttpResponse |
withHeader(Header header)
Add a header to return as a Header object, if a header with the same name already exists this will NOT be modified but two headers will exist |
HttpResponse |
withHeader(String name,
String... values)
Add a header to return as a Header object, if a header with the same name already exists this will NOT be modified but two headers will exist |
HttpResponse |
withHeaders(Header... headers)
The headers to return as a varargs of Header objects |
HttpResponse |
withHeaders(List<Header> headers)
The headers to return as a list of Header objects |
HttpResponse |
withStatusCode(Integer statusCode)
The status code to return, such as 200, 404, the status code specified here will result in the default status message for this status code for example for 200 the status message "OK" is used |
| Methods inherited from class org.mockserver.model.ObjectWithJsonToString |
|---|
toString |
| Methods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString |
|---|
addFieldsExcludedFromEqualsAndHashCode, equals, fieldsExcludedFromEqualsAndHashCode, hashCode |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public HttpResponse()
| Method Detail |
|---|
public static HttpResponse response()
public static HttpResponse response(String body)
public static HttpResponse notFoundResponse()
public HttpResponse withStatusCode(Integer statusCode)
statusCode - an integer such as 200 or 404public Integer getStatusCode()
public HttpResponse withBody(String body)
withBody(String, Charset).
body - a string
public HttpResponse withBody(String body,
Charset charset)
body - a stringcharset - character set the string will be encoded inpublic HttpResponse withBody(byte[] body)
body - a byte arraypublic HttpResponse withBody(Body body)
body - an instance of one of the Body subclasses including StringBody or BinaryBodypublic Body getBody()
public String getBodyAsString()
public HttpResponse withHeaders(List<Header> headers)
headers - a list of Header objectspublic HttpResponse withHeaders(Header... headers)
headers - a varargs of Header objectspublic HttpResponse withHeader(Header header)
header - a Header objects
public HttpResponse withHeader(String name,
String... values)
name - the header namevalues - the header values which can be a varags of strings or regular expressionspublic HttpResponse updateHeader(Header header)
header - a Header objects
public HttpResponse updateHeader(String name,
String... values)
name - the header namevalues - the header values which can be a varags of strings or regular expressionspublic List<Header> getHeaders()
public List<String> getHeader(String name)
public String getFirstHeader(String name)
public HttpResponse withCookies(List<Cookie> cookies)
cookies - a list of Cookie objectspublic HttpResponse withCookies(Cookie... cookies)
cookies - a varargs of Cookie objectspublic HttpResponse withCookie(Cookie cookie)
cookie - a Cookie object
public HttpResponse withCookie(String name,
String value)
name - the cookies namevalue - the cookies value which can be a string or regular expressionpublic List<Cookie> getCookies()
public HttpResponse withDelay(Delay delay)
delay - a Delay object, for example new Delay(TimeUnit.SECONDS, 3)
public HttpResponse withDelay(TimeUnit timeUnit,
long value)
timeUnit - a the time unit, for example TimeUnit.SECONDSvalue - a the number of time units to delay the responsepublic Delay getDelay()
public HttpResponse withConnectionOptions(ConnectionOptions connectionOptions)
connectionOptions - the connection options for override the default connection behaviourpublic ConnectionOptions getConnectionOptions()
public HttpResponse applyDelay()
public Action.Type getType()
getType in class Actionpublic HttpResponse shallowClone()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||