public class ClientResponse extends 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 javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate<Date> |
dateDelegate |
protected static javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate<javax.ws.rs.core.EntityTag> |
entityTagDelegate |
Constructor and Description |
---|
ClientResponse(int status,
InBoundHeaders headers,
InputStream entity,
MessageBodyWorkers workers) |
Modifier and Type | Method and Description |
---|---|
void |
bufferEntity()
Buffer the entity.
|
void |
close()
Close the response.
|
Set<String> |
getAllow()
Get the allowed HTTP methods from the Allow HTTP header.
|
Client |
getClient()
Get the client.
|
ClientResponse.Status |
getClientResponseStatus()
Get the status code.
|
List<javax.ws.rs.core.NewCookie> |
getCookies()
Get the list of cookies.
|
<T> T |
getEntity(Class<T> c)
Get the entity of the response.
|
<T> T |
getEntity(GenericType<T> gt)
Get the entity of the response.
|
InputStream |
getEntityInputStream()
Get the input stream of the response.
|
javax.ws.rs.core.EntityTag |
getEntityTag()
Get the entity tag.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getHeaders()
Get the HTTP headers of the response.
|
String |
getLanguage()
Get the language.
|
Date |
getLastModified()
Get the last modified date.
|
int |
getLength()
Get Content-Length.
|
WebResourceLinkHeaders |
getLinks() |
URI |
getLocation()
Get the location.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getMetadata()
Deprecated.
|
Map<String,Object> |
getProperties()
Get the map of response properties.
|
Date |
getResponseDate()
Get response date (server side).
|
javax.ws.rs.core.Response.Status |
getResponseStatus()
Deprecated.
|
int |
getStatus()
Get the status code.
|
javax.ws.rs.core.MediaType |
getType()
Get the media type of the response.
|
boolean |
hasEntity()
Checks if there is an entity available.
|
void |
setEntityInputStream(InputStream entity)
Set the input stream of the response.
|
void |
setResponseStatus(javax.ws.rs.core.Response.StatusType status)
Deprecated.
|
void |
setStatus(int status)
Set the status code.
|
void |
setStatus(javax.ws.rs.core.Response.StatusType status)
Set the status code.
|
String |
toString() |
protected static final javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate<javax.ws.rs.core.EntityTag> entityTagDelegate
protected static final javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate<Date> dateDelegate
public ClientResponse(int status, InBoundHeaders headers, InputStream entity, MessageBodyWorkers workers)
public Client getClient()
public Map<String,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(javax.ws.rs.core.Response.StatusType status)
status
- the status code.public ClientResponse.Status getClientResponseStatus()
setStatus(int)
and there is no
mapping between the integer value and the Response.Status
enumeration value.@Deprecated public javax.ws.rs.core.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(javax.ws.rs.core.Response.StatusType status)
setStatus(javax.ws.rs.core.Response.StatusType)
status
- the status code.@Deprecated public javax.ws.rs.core.MultivaluedMap<String,String> getMetadata()
public javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
public boolean hasEntity()
public InputStream getEntityInputStream()
public void setEntityInputStream(InputStream entity)
entity
- the input stream of the response.public <T> T getEntity(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 javax.ws.rs.core.MediaType getType()
public URI getLocation()
null
if not present.public javax.ws.rs.core.EntityTag getEntityTag()
null
if not present.public Date getLastModified()
null
if not present.public Date getResponseDate()
null
if not present.public String getLanguage()
null
if not present.public int getLength()
public List<javax.ws.rs.core.NewCookie> getCookies()
public Set<String> getAllow()
Note that the Allow HTTP header will be returned from an OPTIONS request.
public WebResourceLinkHeaders getLinks()
Copyright © 2013 Oracle Corporation. All rights reserved.