]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ETag.cc
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
15 * Note: ETag is not an http "field" like, for example HttpHdrRange. ETag is a
16 * field-value that maybe used in many http fields.
19 /// whether etag strings match
21 etagStringsMatch(const ETag
&tag1
, const ETag
&tag2
)
23 return !strcmp(tag1
.str
, tag2
.str
);
26 /* parses a string as weak or strong entity-tag; returns true on success */
27 /* note: we do not duplicate "str"! */
29 etagParseInit(ETag
* etag
, const char *str
)
34 etag
->weak
= !strncmp(str
, "W/", 2);
39 /* check format (quoted-string) */
42 if (len
>= 2 && str
[0] == '"' && str
[len
- 1] == '"')
45 return etag
->str
!= nullptr;
49 etagIsStrongEqual(const ETag
&tag1
, const ETag
&tag2
)
51 return !tag1
.weak
&& !tag2
.weak
&& etagStringsMatch(tag1
, tag2
);
55 etagIsWeakEqual(const ETag
&tag1
, const ETag
&tag2
)
57 return etagStringsMatch(tag1
, tag2
);