Refactor eTag formatting into utility method
See gh-33412
This commit is contained in:
@@ -134,6 +134,15 @@ public record ETag(String tag, boolean weak) {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String format(String etag) {
|
||||
if (!etag.startsWith("\"") && !etag.startsWith("W/\"")) {
|
||||
etag = "\"" + etag;
|
||||
}
|
||||
if (!etag.endsWith("\"")) {
|
||||
etag = etag + "\"";
|
||||
}
|
||||
return etag;
|
||||
}
|
||||
|
||||
private enum State {
|
||||
|
||||
|
||||
@@ -570,12 +570,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||
@Override
|
||||
public BodyBuilder eTag(@Nullable String etag) {
|
||||
if (etag != null) {
|
||||
if (!etag.startsWith("\"") && !etag.startsWith("W/\"")) {
|
||||
etag = "\"" + etag;
|
||||
}
|
||||
if (!etag.endsWith("\"")) {
|
||||
etag = etag + "\"";
|
||||
}
|
||||
etag = ETag.format(etag);
|
||||
}
|
||||
this.headers.setETag(etag);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user