com.jayway.restassured.response
Interface Response

All Superinterfaces:
ResponseBody
All Known Implementing Classes:
RestAssuredResponseImpl

public interface Response
extends ResponseBody

The response of a request made by REST Assured.

Usage example:

 Response response = get("/lotto");
 String body = response.getBody().asString();
 String headerValue = response.getHeader("headerName");
 String cookieValue = response.getCookie("cookieName");
 

You can also map the response body to a Java object automatically. REST Assured will use Jackson, Gson and JAXB to accommodate this:

 Message message = get("/message").as(Message.class);
 


Method Summary
 Response andReturn()
          Syntactic sugar, simply returns the same response instance.
 ResponseBody body()
          Returns the response body
 String contentType()
          Get the content type of the response
 String cookie(String name)
          Get a single cookie value associated with the given name.
 Map<String,String> cookies()
          The response cookies as simple name/value pair.
 Cookie detailedCookie(String name)
          Get a single cookie including all attributes associated with the given name.
 Cookies detailedCookies()
          The response cookies with all the attributes.
 ResponseBody getBody()
          Returns the response body
 String getContentType()
          Get the content type of the response
 String getCookie(String name)
          Get a single cookie value associated with the given name.
 Map<String,String> getCookies()
          The response cookies as simple name/value pair.
 Cookie getDetailedCookie(String name)
          Get a single cookie including all attributes associated with the given name.
 Cookies getDetailedCookies()
          The response cookies with all the attributes.
 String getHeader(String name)
          Get a single header value associated with the given name.
 Headers getHeaders()
          The response headers.
 String getSessionId()
          Get the session id from the response.
 int getStatusCode()
          Get the status code of the response.
 String getStatusLine()
          Get the status line of the response.
 String header(String name)
          Get a single header value associated with the given name.
 Headers headers()
          The response headers.
 String sessionId()
          Get the session id from the response.
 int statusCode()
          Get the status code of the response.
 String statusLine()
          Get the status line of the response.
 Response thenReturn()
          Syntactic sugar, simply returns the same response instance.
 
Methods inherited from interface com.jayway.restassured.response.ResponseBody
as, as, asByteArray, asInputStream, asString, jsonPath, path, prettyPrint, print, xmlPath
 

Method Detail

andReturn

Response andReturn()
Syntactic sugar, simply returns the same response instance.

Returns:
The same response instance.

thenReturn

Response thenReturn()
Syntactic sugar, simply returns the same response instance.

Returns:
The same response instance.

body

ResponseBody body()
Returns the response body

Returns:
The response body.

getBody

ResponseBody getBody()
Returns the response body

Returns:
The response body.

headers

Headers headers()
The response headers. If there are several response headers with the same name a list of the response header values are returned.

Returns:
The response headers.

getHeaders

Headers getHeaders()
The response headers. If there are several response headers with the same name a list of the response header values are returned.

Returns:
The response headers.

header

String header(String name)
Get a single header value associated with the given name. If the header is a multi-value header then you need to use Headers.getList(String) in order to get all values.

Returns:
The header value or null if value was not found.

getHeader

String getHeader(String name)
Get a single header value associated with the given name. If the header is a multi-value header then you need to use Headers.getList(String) in order to get all values..

Returns:
The header value or null if value was not found.

cookies

Map<String,String> cookies()
The response cookies as simple name/value pair. It assumes that no cookies have the same name. If two cookies should never the less have the same name the first cookie value is used. If you want to return ALL cookies including all the details such as Max-Age etc use detailedCookies().

Returns:
The response cookies.

detailedCookies

Cookies detailedCookies()
The response cookies with all the attributes. It also gives you the possibility to get multi-value cookies.

Returns:
The response cookies.

getCookies

Map<String,String> getCookies()
The response cookies as simple name/value pair. It assumes that no cookies have the same name. If two cookies should never the less have the same name the first cookie value is used. If you want to return ALL cookies inlucding all the details such as Max-Age etc use getDetailedCookies().

Returns:
The response cookies.

getDetailedCookies

Cookies getDetailedCookies()
The response cookies with all the attributes. It also gives you the possibility to get multi-value cookies.

Returns:
The response cookies.

cookie

String cookie(String name)
Get a single cookie value associated with the given name. If you want more details than just the value use detailedCookie(String).

Returns:
The cookie value or null if value was not found.

getCookie

String getCookie(String name)
Get a single cookie value associated with the given name. If you want more details than just the value use getDetailedCookie(String).

Returns:
The cookie value or null if value was not found.

detailedCookie

Cookie detailedCookie(String name)
Get a single cookie including all attributes associated with the given name.

Returns:
The cookie value or null if value was not found.

getDetailedCookie

Cookie getDetailedCookie(String name)
Get a single cookie including all attributes associated with the given name.

Returns:
The cookie value or null if value was not found.

contentType

String contentType()
Get the content type of the response

Returns:
The content type value or null if not found.

getContentType

String getContentType()
Get the content type of the response

Returns:
The content type value or null if not found.

statusLine

String statusLine()
Get the status line of the response.

Returns:
The status line of the response.

getStatusLine

String getStatusLine()
Get the status line of the response.

Returns:
The status line of the response.

sessionId

String sessionId()
Get the session id from the response. The session id name can be configured from the SessionConfig.

Returns:
The session id of the response or null if not defined.

getSessionId

String getSessionId()
Get the session id from the response. The session id name can be configured from the SessionConfig.

Returns:
The session id of the response or null if not defined.

statusCode

int statusCode()
Get the status code of the response.

Returns:
The status code of the response.

getStatusCode

int getStatusCode()
Get the status code of the response.

Returns:
The status code of the response.


Copyright © 2010-2012. All Rights Reserved.