Package org.restlet.util
Class WrapperResponse
java.lang.Object
org.restlet.Message
org.restlet.Response
org.restlet.util.WrapperResponse
Request wrapper. Useful for application developer who need to enrich the
request with application related properties and behavior.
- Author:
- Jerome Louvel
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Ask the connector to abort the related network connection, for example immediately closing the socket.voidcommit()Asks the server connector to immediately commit the given response, making it ready to be sent back to the client.intgetAge()Returns the estimated amount of time since a response was generated or revalidated by the origin server.Returns the set of methods allowed on the requested resource.Returns a modifiable attributes map that can be used by developers to save information relative to the message.Returns information sent by an origin server related to an successful authentication attempt.Returns the list of authentication requests sent by an origin server to a client.Returns the cookie settings provided by the server.Returns the set of selecting dimensions on which the response entity may vary.Returns the entity representation.Returns the reference that the client should follow for redirections or resource creations.Returns the list of authentication requests sent by a proxy to a client.Returns the associated requestIndicates how long the service is expected to be unavailable to the requesting client.Returns the server-specific information.Returns the status.protected ResponseReturns the wrapped response.booleanIndicates if the response should be automatically committed.booleanIndicates if the response has already been committed.booleanIndicates if the call came over a confidential channel such as an SSL-secured connection.booleanIndicates if a content is available and can be sent.voidredirectPermanent(String targetUri) Permanently redirects the client to a target URI.voidredirectPermanent(Reference targetRef) Permanently redirects the client to a target URI.voidredirectSeeOther(String targetUri) Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.voidredirectSeeOther(Reference targetRef) Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.voidredirectTemporary(String targetUri) Temporarily redirects the client to a target URI.voidredirectTemporary(Reference targetRef) Temporarily redirects the client to a target URI.voidsetAge(int age) Sets the estimated amount of time since a response was generated or revalidated by the origin server.voidsetAllowedMethods(Set<Method> allowedMethods) Sets the set of methods allowed on the requested resource.voidsetAuthenticationInfo(AuthenticationInfo authenticationInfo) Sets the authentication information sent by an origin server to a client after a successful authentication attempt.
Note that when used with HTTP connectors, this property maps to the "Authentication-Info" header.voidsetAutoCommitting(boolean autoCommitting) Indicates if the response should be automatically committed.voidsetChallengeRequests(List<ChallengeRequest> requests) Sets the list of authentication requests sent by an origin server to a client.voidsetCommitted(boolean committed) Indicates if the response has already been committed.voidsetCookieSettings(Series<CookieSetting> cookieSettings) Sets the modifiable series of cookie settings provided by the server.voidsetDimensions(Set<Dimension> dimensions) Sets the set of dimensions on which the response entity may vary.voidSets a textual entity.voidsetEntity(Representation entity) Sets the entity representation.voidsetLocationRef(String locationUri) Sets the reference that the client should follow for redirections or resource creations.voidsetLocationRef(Reference locationRef) Sets the reference that the client should follow for redirections or resource creations.voidsetProxyChallengeRequests(List<ChallengeRequest> requests) Sets the list of authentication requests sent by a proxy to a client.voidsetRequest(Request request) Sets the associated request.voidsetRequest(WrapperRequest request) Sets the associated request.voidsetRetryAfter(Date retryAfter) Indicates how long the service is expected to be unavailable to the requesting client.voidsetServerInfo(ServerInfo serverInfo) Sets the server-specific information.voidSets the status.voidSets the status.voidSets the status.voidSets the status.toString()Displays a synthesis of the response like an HTTP status line.Methods inherited from class org.restlet.Response
flushBuffers, getAccessControlAllowCredentials, getAccessControlAllowHeaders, getAccessControlAllowMethods, getAccessControlAllowOrigin, getAccessControlExposeHeaders, getAccessControlMaxAge, getCurrent, isFinal, isProvisional, setAccessControlAllowCredentials, setAccessControlAllowHeaders, setAccessControlAllowMethods, setAccessControlAllowOrigin, setAccessControlExposeHeaders, setAccessControlMaxAge, setCurrentMethods inherited from class org.restlet.Message
bufferEntity, getCacheDirectives, getDate, getEntityAsText, getHeaders, getOnError, getOnSent, getRecipientsInfo, getWarnings, release, setAttributes, setCacheDirectives, setDate, setOnError, setOnSent, setRecipientsInfo, setWarnings
-
Constructor Details
-
WrapperResponse
Constructor.- Parameters:
wrappedResponse- The wrapped response.
-
-
Method Details
-
abort
public void abort()Description copied from class:ResponseAsk the connector to abort the related network connection, for example immediately closing the socket. -
commit
public void commit()Description copied from class:ResponseAsks the server connector to immediately commit the given response, making it ready to be sent back to the client. Note that all server connectors don't necessarily support this feature.
When the response is in autoCommit mode (see related property), then calling this method isn't necessary. Also, be aware that committing the response doesn't necessarily means that is will be immediately be written on the network as some buffering can occurs. If you want to ensure that response buffers are flushed,
Note that this calls backRequest.commit(Response)on the parent request which holds the link with the underlying network connection. -
getAge
public int getAge()Description copied from class:ResponseReturns the estimated amount of time since a response was generated or revalidated by the origin server. Origin servers should leave the 0 default value. Only caches are expected to set this property.
Note that when used with HTTP connectors, this property maps to the "Age" header. -
getAllowedMethods
Returns the set of methods allowed on the requested resource. This property only has to be updated when a status CLIENT_ERROR_METHOD_NOT_ALLOWED is set.- Overrides:
getAllowedMethodsin classResponse- Returns:
- The list of allowed methods.
-
getAttributes
Returns a modifiable attributes map that can be used by developers to save information relative to the message. This is an easier alternative to the creation of a wrapper instance around the whole message.
In addition, this map is a shared space between the developer and the connectors. In this case, it is used to exchange information that is not uniform across all protocols and couldn't therefore be directly included in the API. For this purpose, all attribute names starting with "org.restlet" are reserved. Currently the following attributes are used:
Adding standard HTTP headers is forbidden because it could conflict with the connector's internal behavior, limit portability or prevent future optimizations.list of supported attributes Attribute name Class name Description org.restlet.http.headers org.restlet.data.Form Server HTTP connectors must provide all request headers and client HTTP connectors must provide all response headers, exactly as they were received. In addition, developers can also use this attribute to specify non-standard headers that should be added to the request or to the response. - Overrides:
getAttributesin classMessage- Returns:
- The modifiable attributes map.
-
getAuthenticationInfo
Description copied from class:ResponseReturns information sent by an origin server related to an successful authentication attempt. If none is available, null is returned.
Note that when used with HTTP connectors, this property maps to the "Authentication-Info" header.- Overrides:
getAuthenticationInfoin classResponse- Returns:
- The authentication information provided by the server.
-
getChallengeRequests
Returns the list of authentication requests sent by an origin server to a client.- Overrides:
getChallengeRequestsin classResponse- Returns:
- The list of authentication requests sent by an origin server to a client.
-
getCookieSettings
Returns the cookie settings provided by the server.- Overrides:
getCookieSettingsin classResponse- Returns:
- The cookie settings provided by the server.
-
getDimensions
Returns the set of selecting dimensions on which the response entity may vary. If some server-side content negotiation is done, this set should be properly updated, other it can be left empty.- Overrides:
getDimensionsin classResponse- Returns:
- The set of dimensions on which the response entity may vary.
-
getEntity
Returns the entity representation. -
getLocationRef
Returns the reference that the client should follow for redirections or resource creations.- Overrides:
getLocationRefin classResponse- Returns:
- The redirection reference.
-
getProxyChallengeRequests
Returns the list of authentication requests sent by a proxy to a client.- Overrides:
getProxyChallengeRequestsin classResponse- Returns:
- The list of authentication requests sent by a proxy to a client.
-
getRequest
Returns the associated request- Overrides:
getRequestin classResponse- Returns:
- The associated request
-
getRetryAfter
Description copied from class:ResponseIndicates how long the service is expected to be unavailable to the requesting client. Default value is null.
Note that when used with HTTP connectors, this property maps to the "Retry-After" header.- Overrides:
getRetryAfterin classResponse- Returns:
- Date after with a retry attempt could occur.
-
getServerInfo
Returns the server-specific information.- Overrides:
getServerInfoin classResponse- Returns:
- The server-specific information.
-
getStatus
Returns the status. -
getWrappedResponse
Returns the wrapped response.- Returns:
- The wrapped response.
-
isAutoCommitting
public boolean isAutoCommitting()Description copied from class:ResponseIndicates if the response should be automatically committed. When processing a request on the server-side, setting this property to 'false' let you ask to the server connector to wait before sending the response back to the client when the initial calling thread returns. This will let you do further updates to the response and manually callingResponse.commit()later on, using another thread.- Overrides:
isAutoCommittingin classResponse- Returns:
- True if the response should be automatically committed.
-
isCommitted
public boolean isCommitted()Description copied from class:ResponseIndicates if the response has already been committed.- Overrides:
isCommittedin classResponse- Returns:
- True if the response has already been committed.
-
isConfidential
public boolean isConfidential()Indicates if the call came over a confidential channel such as an SSL-secured connection.- Overrides:
isConfidentialin classResponse- Returns:
- True if the call came over a confidential channel.
-
isEntityAvailable
public boolean isEntityAvailable()Indicates if a content is available and can be sent. Several conditions must be met: the content must exists and have some available data.- Overrides:
isEntityAvailablein classMessage- Returns:
- True if a content is available and can be sent.
-
redirectPermanent
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.- Overrides:
redirectPermanentin classResponse- Parameters:
targetRef- The target URI reference.
-
redirectPermanent
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.- Overrides:
redirectPermanentin classResponse- Parameters:
targetUri- The target URI.
-
redirectSeeOther
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.- Overrides:
redirectSeeOtherin classResponse- Parameters:
targetRef- The target reference.
-
redirectSeeOther
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.- Overrides:
redirectSeeOtherin classResponse- Parameters:
targetUri- The target URI.
-
redirectTemporary
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.- Overrides:
redirectTemporaryin classResponse- Parameters:
targetRef- The target reference.
-
redirectTemporary
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.- Overrides:
redirectTemporaryin classResponse- Parameters:
targetUri- The target URI.
-
setAge
public void setAge(int age) Description copied from class:ResponseSets the estimated amount of time since a response was generated or revalidated by the origin server. Origin servers should leave the 0 default value. Only caches are expected to set this property.
Note that when used with HTTP connectors, this property maps to the "Age" header. -
setAllowedMethods
Description copied from class:ResponseSets the set of methods allowed on the requested resource. The set instance set must be thread-safe (useCopyOnWriteArraySetfor example.
Note that when used with HTTP connectors, this property maps to the "Allow" header.- Overrides:
setAllowedMethodsin classResponse- Parameters:
allowedMethods- The set of methods allowed on the requested resource.
-
setAuthenticationInfo
Description copied from class:ResponseSets the authentication information sent by an origin server to a client after a successful authentication attempt.
Note that when used with HTTP connectors, this property maps to the "Authentication-Info" header.- Overrides:
setAuthenticationInfoin classResponse- Parameters:
authenticationInfo- The data returned by the server in response to successful authentication.
-
setAutoCommitting
public void setAutoCommitting(boolean autoCommitting) Description copied from class:ResponseIndicates if the response should be automatically committed.- Overrides:
setAutoCommittingin classResponse- Parameters:
autoCommitting- True if the response should be automatically committed
-
setChallengeRequests
Sets the list of authentication requests sent by an origin server to a client.- Overrides:
setChallengeRequestsin classResponse- Parameters:
requests- The list of authentication requests sent by an origin server to a client.
-
setCommitted
public void setCommitted(boolean committed) Description copied from class:ResponseIndicates if the response has already been committed.- Overrides:
setCommittedin classResponse- Parameters:
committed- True if the response has already been committed.
-
setCookieSettings
Description copied from class:ResponseSets the modifiable series of cookie settings provided by the server. Note that when used with HTTP connectors, this property maps to the "Set-Cookie" and "Set-Cookie2" headers. This method clears the current series and adds all entries in the parameter series.- Overrides:
setCookieSettingsin classResponse- Parameters:
cookieSettings- A series of cookie settings provided by the server.
-
setDimensions
Description copied from class:ResponseSets the set of dimensions on which the response entity may vary. Note that when used with HTTP connectors, this property maps to the "Vary" header. This method clears the current set and adds all entries in the parameter set.- Overrides:
setDimensionsin classResponse- Parameters:
dimensions- The set of dimensions on which the response entity may vary.
-
setEntity
Sets the entity representation. -
setEntity
Sets a textual entity. -
setLocationRef
Sets the reference that the client should follow for redirections or resource creations.- Overrides:
setLocationRefin classResponse- Parameters:
locationRef- The reference to set.
-
setLocationRef
Sets the reference that the client should follow for redirections or resource creations.- Overrides:
setLocationRefin classResponse- Parameters:
locationUri- The URI to set.- See Also:
-
setProxyChallengeRequests
Sets the list of authentication requests sent by a proxy to a client.- Overrides:
setProxyChallengeRequestsin classResponse- Parameters:
requests- The list of authentication requests sent by a proxy to a client.
-
setRequest
Sets the associated request.- Overrides:
setRequestin classResponse- Parameters:
request- The associated request
-
setRequest
Sets the associated request.- Parameters:
request- The associated request
-
setRetryAfter
Description copied from class:ResponseIndicates how long the service is expected to be unavailable to the requesting client. Default value is null.
Note that when used with HTTP connectors, this property maps to the "Retry-After" header.- Overrides:
setRetryAfterin classResponse- Parameters:
retryAfter- Date after with a retry attempt could occur.
-
setServerInfo
Description copied from class:ResponseSets the server-specific information.- Overrides:
setServerInfoin classResponse- Parameters:
serverInfo- The server-specific information.
-
setStatus
Sets the status. -
setStatus
Sets the status. -
setStatus
Description copied from class:ResponseSets the status. -
setStatus
Description copied from class:ResponseSets the status. -
toString
Description copied from class:ResponseDisplays a synthesis of the response like an HTTP status line.
-