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");
 

The response can only be returned if you don't use any expectations on the body. E.g.

 expect().body(equalTo("my body")).when().get("/something").asString()
 
will throw an IllegalStateException because of the body expectation matcher.


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.
 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.
 String getHeader(String name)
          Get a single header value associated with the given name.
 Map<String,String> getHeaders()
          The response headers.
 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.
 Map<String,String> headers()
          The response headers.
 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
asByteArray, asString, print
 

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

Map<String,String> headers()
The response headers.

Returns:
The response headers.

getHeaders

Map<String,String> getHeaders()
The response headers.

Returns:
The response headers.

header

String header(String name)
Get a single header value associated with the given name.

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.

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

cookies

Map<String,String> cookies()
The response cookies.

Returns:
The response cookies.

getCookies

Map<String,String> getCookies()
The response cookies.

Returns:
The response cookies.

cookie

String cookie(String name)
Get a single cookie value associated with the given name.

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.

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.

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-2011. All Rights Reserved.