* field-value that maybe used in many http fields.
*/
+/// whether etag strings match
+static bool
+etagStringsMatch(const ETag &tag1, const ETag &tag2)
+{
+ return !strcmp(tag1.str, tag2.str);
+}
+
/* parses a string as weak or strong entity-tag; returns true on success */
/* note: we do not duplicate "str"! */
int
return etag->str != NULL;
}
-/* returns true if etags are equal */
-int
-etagIsEqual(const ETag * tag1, const ETag * tag2)
+bool
+etagIsStrongEqual(const ETag &tag1, const ETag &tag2)
+{
+ return !tag1.weak && !tag2.weak && etagStringsMatch(tag1, tag2);
+}
+
+bool
+etagIsWeakEqual(const ETag &tag1, const ETag &tag2)
{
- assert(tag1 && tag2);
- assert(!tag1->weak && !tag2->weak); /* weak comparison not implemented yet */
- return !strcmp(tag1->str, tag2->str);
+ return etagStringsMatch(tag1, tag2);
}
return 0; /* must use strong validator for sub-range requests */
}
- return etagIsEqual(&rep_tag, &spec.tag);
+ return etagIsStrongEqual(rep_tag, spec.tag);
}
/* got modification time? */
/* ETag */
SQUIDCEXTERN int etagParseInit(ETag * etag, const char *str);
-SQUIDCEXTERN int etagIsEqual(const ETag * tag1, const ETag * tag2);
+/// whether etags are strong-equal
+SQUIDCEXTERN bool etagIsStrongEqual(const ETag &tag1, const ETag &tag2);
+/// whether etags are weak-equal
+SQUIDCEXTERN bool etagIsWeakEqual(const ETag &tag1, const ETag &tag2);
#include "HttpStatusCode.h"
SQUIDCEXTERN const char *httpStatusString(http_status status);