From bffa939c44edcbcad2b80d4d1f7405bf164a0227 Mon Sep 17 00:00:00 2001 From: Thierry Boileau Date: Sun, 29 Nov 2026 18:08:20 +0100 Subject: [PATCH] Document that new Tag(String) creates a weak entity tag (#1694) RFC 9110 section 8.8.3 defines an entity tag as strong unless it carries the "W/" prefix, whereas Tag() and Tag(String) create a weak tag, written as W/"value", which never matches an If-Match or If-Range condition. The behaviour is not changed in this maintenance version (it would alter the ETag header of existing servers); the Javadoc says so and points to new Tag(value, false). Restlet 3.0 creates a strong tag. Co-Authored-By: Claude Sonnet 5.5 --- changes.md | 1 + .../src/main/java/org/restlet/data/Tag.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changes.md b/changes.md index 7e0702762d..5693e046aa 100644 --- a/changes.md +++ b/changes.md @@ -28,6 +28,7 @@ Changes log - `CacheDirective.noCache(String)`, `noCache(List)`, `privateInfo(String)` and `privateInfo(List)` produced a doubly quoted value (`no-cache="\"Set-Cookie\""`), and a list was written as one quoted name per element. The directive value now holds the raw field names (`Set-Cookie`, or `Set-Cookie, Authorization` for a list, no quotes), and `CacheDirectiveWriter` writes them as a single quoted-string (`no-cache="Set-Cookie, Authorization"`), as required by RFC 9111 section 5.2.2.4. Code reading `getValue()` of these directives no longer sees the quotes. Issue #745. - Enhancements + - Documented that `new Tag()` and `new Tag(String)` create a weak entity tag, which is written as `W/"value"` and never matches an `If-Match` or `If-Range` condition: use `new Tag(value, false)` for a strong tag. The behaviour is unchanged. Issue #1694. - `Redirector.MODE_CLIENT_PERMANENT_STRICT` answers 308 (Permanent Redirect), which makes the client repeat the request with the same method and content, unlike `MODE_CLIENT_PERMANENT` (301) that lets a user agent turn a POST into a GET. It comes with `Response.redirectPermanentStrict(...)`, `ServerResource.redirectPermanentStrict(...)` and `Router.redirectPermanentStrict(...)`. The Javadoc of the 301 helpers no longer promises that the method is kept. Issue #1746. - Misc - Added conditional writes on the client side: `ClientResource` gets per-call overloads `put`, `patch` and `delete` taking `Conditions`; they apply to that call only and are never retried. `Conditions.unchangedSince(Response)` builds an "If-Match" condition from the strong entity tag that was read, or an "If-Unmodified-Since" condition if the modification date can be deduced to be strong (the response date is at least one second after it, RFC 9110 section 8.8.2.2), and refuses to build an unconditional write otherwise. `Conditions.ifAbsent()` builds "If-None-Match: *" to create a resource only if it does not exist. A failed condition is reported as a 412 `ResourceException`. Issue #100. diff --git a/org.restlet.java/org.restlet/src/main/java/org/restlet/data/Tag.java b/org.restlet.java/org.restlet/src/main/java/org/restlet/data/Tag.java index 53df708eb5..804c8bd4bf 100644 --- a/org.restlet.java/org.restlet/src/main/java/org/restlet/data/Tag.java +++ b/org.restlet.java/org.restlet/src/main/java/org/restlet/data/Tag.java @@ -78,14 +78,21 @@ public static Tag parse(String httpTag) { /** * Default constructor. The opaque tag is set to null and the weakness indicator - * is set to true. + * is set to true: the tag is weak, see {@link #Tag(String)}. */ public Tag() { this(null, true); } /** - * Constructor of weak tags. + * Constructor of weak tags.
+ *
+ * Note that RFC 9110 section 8.8.3 defines an entity tag as strong unless it + * carries the "W/" prefix, whereas this constructor creates a weak tag: + * it is written as {@code W/"value"} and never matches an "If-Match" or + * "If-Range" condition (strong comparison). To create a tag that clients can + * use to update or resume a representation, use {@code new Tag(value, false)}. + * Restlet 3.0 creates a strong tag here. * * @param opaqueTag The tag value. */