-
public interface Request
An injectable helper for request processing, all methods throw anIllegalStateException
if called outside the scope of a request (e.g. from a provider constructor). Precondition processing (see theevaluatePreconditions
methods) can result in either anull
return value to indicate that preconditions have been met and that the request should continue, or a non-null
return value to indicate that preconditions were not met. In the event that preconditions were not met, the returnedResponseBuilder
instance will have an appropriate status and will also include aVary
header if theselectVariant(List)
method was called prior to to callingevaluatePreconditions
. It is the responsibility of the caller to check the status and add additional metadata if required. E.g., see HTTP/1.1, section 10.3.5 for details of the headers that are expected to accompany a304 Not Modified
response.- Since:
- 1.0
- Author:
- Paul Sandoz, Marc Hadley, Marek Potociar
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Response.ResponseBuilder
evaluatePreconditions()
Evaluate request preconditions for a resource that does not currently exist.Response.ResponseBuilder
evaluatePreconditions(Date lastModified)
Evaluate request preconditions based on the passed in value.Response.ResponseBuilder
evaluatePreconditions(Date lastModified, EntityTag eTag)
Evaluate request preconditions based on the passed in value.Response.ResponseBuilder
evaluatePreconditions(EntityTag eTag)
Evaluate request preconditions based on the passed in value.String
getMethod()
Get the request method, e.g.Variant
selectVariant(List<Variant> variants)
Select the representation variant that best matches the request.
-
-
-
Method Detail
-
getMethod
String getMethod()
Get the request method, e.g. GET, POST, etc.- Returns:
- the request method.
- See Also:
HttpMethod
-
selectVariant
Variant selectVariant(List<Variant> variants)
Select the representation variant that best matches the request. Returnsnull
in case there is no matching variant in the list.More explicit variants are chosen ahead of less explicit ones. A vary header is computed from the supplied list and automatically added to the response.
- Parameters:
variants
- a list of Variant that describe all of the available representation variants.- Returns:
- the variant that best matches the request or
null
if there's no match. - Throws:
IllegalArgumentException
- if variants is empty ornull
.IllegalStateException
- if called outside the scope of a request.- See Also:
Variant.VariantListBuilder
-
evaluatePreconditions
Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)
Evaluate request preconditions based on the passed in value.- Parameters:
eTag
- an ETag for the current state of the resource- Returns:
null
if the preconditions are met or aResponseBuilder
set with the appropriate status if the preconditions are not met. A returnedResponseBuilder
will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returnedResponseBuilder
would be set toResponse.Status.PRECONDITION_FAILED
.- Throws:
IllegalArgumentException
- if eTag isnull
.IllegalStateException
- if called outside the scope of a request.
-
evaluatePreconditions
Response.ResponseBuilder evaluatePreconditions(Date lastModified)
Evaluate request preconditions based on the passed in value.- Parameters:
lastModified
- a date that specifies the modification date of the resource- Returns:
null
if the preconditions are met or aResponseBuilder
set with the appropriate status if the preconditions are not met.- Throws:
IllegalArgumentException
- if lastModified isnull
.IllegalStateException
- if called outside the scope of a request.
-
evaluatePreconditions
Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag)
Evaluate request preconditions based on the passed in value.- Parameters:
lastModified
- a date that specifies the modification date of the resourceeTag
- an ETag for the current state of the resource- Returns:
null
if the preconditions are met or aResponseBuilder
set with the appropriate status if the preconditions are not met. A returnedResponseBuilder
will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returnedResponseBuilder
would be set toResponse.Status.PRECONDITION_FAILED
.- Throws:
IllegalArgumentException
- if lastModified or eTag isnull
.IllegalStateException
- if called outside the scope of a request.
-
evaluatePreconditions
Response.ResponseBuilder evaluatePreconditions()
Evaluate request preconditions for a resource that does not currently exist. The primary use of this method is to support the If-Match: * and If-None-Match: * preconditions.Note that both preconditions
If-None-Match: *
andIf-None-Match: something
will always be considered to have been met and it is the applications responsibility to enforce any additional method-specific semantics. E.g. aPUT
on a resource that does not exist might succeed whereas aGET
on a resource that does not exist would likely result in a 404 response. It would be the responsibility of the application to generate the 404 response.- Returns:
null
if the preconditions are met or aResponseBuilder
set with the appropriate status if the preconditions are not met.- Throws:
IllegalStateException
- if called outside the scope of a request.- Since:
- 1.1
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/ws/rs/core/Request.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.