Class ETagHelperImpl
- All Implemented Interfaces:
ETagHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckChangePreconditions(String eTag, Collection<String> ifMatchHeaders, Collection<String> ifNoneMatchHeaders) Checks the preconditions of a change request (with HTTP methods PUT, PATCH, or DELETE) with a given ETag value against the If-Match and If-None-Match HTTP headers.booleancheckReadPreconditions(String eTag, Collection<String> ifMatchHeaders, Collection<String> ifNoneMatchHeaders) Checks the preconditions of a read request with a given ETag value against the If-Match and If-None-Match HTTP headers.protected ETagInformationcreateETagInformation(Collection<String> values) Creates ETag information from the values of a HTTP header containing a list of entity tags or a single star character, i.e.,If-MatchandIf-None-Match.
-
Constructor Details
-
ETagHelperImpl
public ETagHelperImpl()
-
-
Method Details
-
checkReadPreconditions
public boolean checkReadPreconditions(String eTag, Collection<String> ifMatchHeaders, Collection<String> ifNoneMatchHeaders) throws PreconditionException Description copied from interface:ETagHelperChecks the preconditions of a read request with a given ETag value against the If-Match and If-None-Match HTTP headers.
If the given ETag value is not matched by the ETag information in the If-Match headers, and there are ETags in the headers to be matched, a "Precondition Failed" exception is thrown.
If the given ETag value is matched by the ETag information in the If-None-Match headers,
trueis returned, and applications are supposed to return an empty response with a "Not Modified" status code and the ETag header,falseotherwise.All matching uses weak comparison as described in RFC 7232, section 2.3.2.
This method does not nothing and returns
falseif the ETag value isnull.- Specified by:
checkReadPreconditionsin interfaceETagHelper- Parameters:
eTag- the ETag value to matchifMatchHeaders- the If-Match header valuesifNoneMatchHeaders- the If-None-Match header values- Returns:
- whether a "Not Modified" response should be used
- Throws:
PreconditionException
-
checkChangePreconditions
public void checkChangePreconditions(String eTag, Collection<String> ifMatchHeaders, Collection<String> ifNoneMatchHeaders) throws PreconditionException Description copied from interface:ETagHelperChecks the preconditions of a change request (with HTTP methods PUT, PATCH, or DELETE) with a given ETag value against the If-Match and If-None-Match HTTP headers.
If the given ETag value is not matched by the ETag information in the If-Match headers, and there are ETags in the headers to be matched, or if the given ETag value is matched by the ETag information in the If-None-Match headers, a "Precondition Failed" exception is thrown.
All matching uses weak comparison as described in RFC 7232, section 2.3.2.
This method does not nothing if the ETag value is
null.- Specified by:
checkChangePreconditionsin interfaceETagHelper- Parameters:
eTag- the ETag value to matchifMatchHeaders- the If-Match header valuesifNoneMatchHeaders- the If-None-Match header values- Throws:
PreconditionException
-
createETagInformation
Creates ETag information from the values of a HTTP header containing a list of entity tags or a single star character, i.e.,If-MatchandIf-None-Match.- Parameters:
values- the collection of header values- Returns:
- an
ETagInformationinstance
-