public class ClientResponse
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ClientResponse.Status
Status codes defined by HTTP, see
HTTP/1.1 documentation.
|
Modifier and Type | Field and Description |
---|---|
protected static RuntimeDelegate.HeaderDelegate<java.util.Date> |
dateDelegate |
protected static RuntimeDelegate.HeaderDelegate<EntityTag> |
entityTagDelegate |
Constructor and Description |
---|
ClientResponse(int statusCode,
InBoundHeaders headers,
java.io.InputStream entity,
MessageBodyWorkers workers)
Create a new instance initialized form
statusCode , headers , entity ,
workers . |
ClientResponse(Response.StatusType statusType,
InBoundHeaders headers,
java.io.InputStream entity,
MessageBodyWorkers workers)
Create a new instance initialized form
statusType , headers , entity ,
workers . |
Modifier and Type | Method and Description |
---|---|
void |
bufferEntity()
Buffer the entity.
|
void |
close()
Close the response.
|
java.util.Set<java.lang.String> |
getAllow()
Get the allowed HTTP methods from the Allow HTTP header.
|
Client |
getClient()
Get the client.
|
ClientResponse.Status |
getClientResponseStatus()
Deprecated.
Deprecated since 1.18. Use
getStatusInfo() which can
return status type even for status codes which
do not have mapping defined in Response.Status . |
java.util.List<NewCookie> |
getCookies()
Get the list of cookies.
|
<T> T |
getEntity(java.lang.Class<T> c)
Get the entity of the response.
|
<T> T |
getEntity(GenericType<T> gt)
Get the entity of the response.
|
java.io.InputStream |
getEntityInputStream()
Get the input stream of the response.
|
EntityTag |
getEntityTag()
Get the entity tag.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getHeaders()
Get the HTTP headers of the response.
|
java.lang.String |
getLanguage()
Get the language.
|
java.util.Date |
getLastModified()
Get the last modified date.
|
int |
getLength()
Get Content-Length.
|
WebResourceLinkHeaders |
getLinks() |
java.net.URI |
getLocation()
Get the location.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getMetadata()
Deprecated.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Get the map of response properties.
|
java.util.Date |
getResponseDate()
Get response date (server side).
|
Response.Status |
getResponseStatus()
Deprecated.
|
int |
getStatus()
Get the status code.
|
Response.StatusType |
getStatusInfo()
Get the
status type . |
MediaType |
getType()
Get the media type of the response.
|
boolean |
hasEntity()
Checks if there is an entity available.
|
void |
setEntityInputStream(java.io.InputStream entity)
Set the input stream of the response.
|
void |
setResponseStatus(Response.StatusType status)
Deprecated.
|
void |
setStatus(int status)
Set the status code.
|
void |
setStatus(Response.StatusType statusType)
Set the
status type . |
java.lang.String |
toString() |
protected static final RuntimeDelegate.HeaderDelegate<EntityTag> entityTagDelegate
protected static final RuntimeDelegate.HeaderDelegate<java.util.Date> dateDelegate
public ClientResponse(Response.StatusType statusType, InBoundHeaders headers, java.io.InputStream entity, MessageBodyWorkers workers)
statusType
, headers
, entity
,
workers
.statusType
- Status type.headers
- HTTP headers.entity
- Entity input stream.workers
- Message body workers.public ClientResponse(int statusCode, InBoundHeaders headers, java.io.InputStream entity, MessageBodyWorkers workers)
statusCode
, headers
, entity
,
workers
.headers
- HTTP headers.entity
- Entity input stream.workers
- Message body workers.public Client getClient()
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
A response property is an application-defined property that may be added by the user, a filter, or the handler that is managing the connection.
public int getStatus()
public void setStatus(int status)
status
- the status code.public void setStatus(Response.StatusType statusType)
status type
.statusType
- the status type code.@Deprecated public ClientResponse.Status getClientResponseStatus()
getStatusInfo()
which can
return status type
even for status codes which
do not have mapping defined in Response.Status
.setStatus(int)
and there is no
mapping between the integer value and the Response.Status
enumeration value.public Response.StatusType getStatusInfo()
status type
. Status type can be describe a standard response status
defined by the HTTP specification and defined in Response.Status
enumeration
but also can contain status codes which are not defined by Response.Status
enumeration (for example custom status code returned from a resource method).@Deprecated public Response.Status getResponseStatus()
getClientResponseStatus()
setStatus(int)
and there is no
mapping between the integer value and the Response.Status
enumeration value.@Deprecated public void setResponseStatus(Response.StatusType status)
setStatus(javax.ws.rs.core.Response.StatusType)
status
- the status code.@Deprecated public MultivaluedMap<java.lang.String,java.lang.String> getMetadata()
public MultivaluedMap<java.lang.String,java.lang.String> getHeaders()
public boolean hasEntity()
public java.io.InputStream getEntityInputStream()
public void setEntityInputStream(java.io.InputStream entity)
entity
- the input stream of the response.public <T> T getEntity(java.lang.Class<T> c) throws ClientHandlerException, UniformInterfaceException
If the entity is not an instance of Closeable then the entity input stream is closed.
T
- the type of the response.c
- the type of the entity.c
.ClientHandlerException
- if there is an error processing the response.UniformInterfaceException
- if the response status is 204 (No Content).public <T> T getEntity(GenericType<T> gt) throws ClientHandlerException, UniformInterfaceException
If the entity is not an instance of Closeable then this response
is closed (you cannot read it more than once, any subsequent
call will produce ClientHandlerException
).
T
- the type of the response.gt
- the generic type of the entity.ClientHandlerException
- if there is an error processing the response.UniformInterfaceException
- if the response status is 204 (No Content).public void bufferEntity() throws ClientHandlerException
All the bytes of the original entity input stream will be read and stored in memory. The original entity input stream will then be closed.
ClientHandlerException
- if there is an error processing the response.public void close() throws ClientHandlerException
The entity input stream is closed.
ClientHandlerException
- if there is an error closing the response.public MediaType getType()
public java.net.URI getLocation()
null
if not present.public EntityTag getEntityTag()
null
if not present.public java.util.Date getLastModified()
null
if not present.public java.util.Date getResponseDate()
null
if not present.public java.lang.String getLanguage()
null
if not present.public int getLength()
public java.util.List<NewCookie> getCookies()
public java.util.Set<java.lang.String> getAllow()
Note that the Allow HTTP header will be returned from an OPTIONS request.
public WebResourceLinkHeaders getLinks()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2016 Oracle Corporation. All Rights Reserved.