Package play.libs.ws
Class HttpResponse
java.lang.Object
play.libs.ws.HttpResponse
- Direct Known Subclasses:
DummyHttpResponse
,HttpAsyncResponse
An HTTP response wrapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe http response content typeabstract String
abstract List<Http.Header>
com.google.gson.JsonElement
getJson()
get the response body as aJsonElement
Parse the response string as a query string.abstract Integer
the HTTP status codeabstract String
The HTTP status textabstract InputStream
get the response as a streamabstract String
get the response body as a stringabstract String
get the response body as a stringgetXml()
Parse and get the response body as aDOM document
parse and get the response body as aDOM document
boolean
success()
-
Constructor Details
-
HttpResponse
public HttpResponse()
-
-
Method Details
-
getStatus
the HTTP status code- Returns:
- the status code of the http response
-
getStatusText
The HTTP status text- Returns:
- the status text of the http response
-
success
public boolean success()- Returns:
- true if the status code is 20x, false otherwise
-
getContentType
The http response content type- Returns:
- the content type of the http response
-
getEncoding
-
getHeader
-
getHeaders
-
getXml
Parse and get the response body as aDOM document
- Returns:
- a DOM document
-
getXml
parse and get the response body as aDOM document
- Parameters:
encoding
- xml charset encoding- Returns:
- a DOM document
-
getString
get the response body as a string- Returns:
- the body of the http response
-
getString
get the response body as a string- Parameters:
encoding
- string charset encoding- Returns:
- the body of the http response
-
getQueryString
Parse the response string as a query string.- Returns:
- The parameters as a Map. Return an empty map if the response is not formed as a query string.
-
getStream
get the response as a stream+ this method can only be called onced because async implementation does not allow it to be called + multiple times +
- Returns:
- an inputstream
-
getJson
public com.google.gson.JsonElement getJson()get the response body as aJsonElement
- Returns:
- the json response
-