]>
Commit | Line | Data |
---|---|---|
a9771e51 | 1 | |
2 | /* | |
262a0e14 | 3 | * $Id$ |
a9771e51 | 4 | * |
f740a279 | 5 | * DEBUG: none ETag parsing support |
a9771e51 | 6 | * AUTHOR: Alex Rousskov |
7 | * | |
2b6662ba | 8 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
e25c139f | 9 | * ---------------------------------------------------------- |
a9771e51 | 10 | * |
2b6662ba | 11 | * Squid is the result of efforts by numerous individuals from |
12 | * the Internet community; see the CONTRIBUTORS file for full | |
13 | * details. Many organizations have provided support for Squid's | |
14 | * development; see the SPONSORS file for full details. Squid is | |
15 | * Copyrighted (C) 2001 by the Regents of the University of | |
16 | * California; see the COPYRIGHT file for full details. Squid | |
17 | * incorporates software developed and/or copyrighted by other | |
18 | * sources; see the CREDITS file for full details. | |
a9771e51 | 19 | * |
20 | * This program is free software; you can redistribute it and/or modify | |
21 | * it under the terms of the GNU General Public License as published by | |
22 | * the Free Software Foundation; either version 2 of the License, or | |
23 | * (at your option) any later version. | |
26ac0430 | 24 | * |
a9771e51 | 25 | * This program is distributed in the hope that it will be useful, |
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 | * GNU General Public License for more details. | |
26ac0430 | 29 | * |
a9771e51 | 30 | * You should have received a copy of the GNU General Public License |
31 | * along with this program; if not, write to the Free Software | |
cbdec147 | 32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
e25c139f | 33 | * |
a9771e51 | 34 | */ |
35 | ||
36 | #include "squid.h" | |
37 | ||
38 | /* | |
39 | * Note: ETag is not an http "field" like, for example HttpHdrRange. ETag is a | |
40 | * field-value that maybe used in many http fields. | |
41 | */ | |
42 | ||
43 | /* parses a string as weak or strong entity-tag; returns true on success */ | |
44 | /* note: we do not duplicate "str"! */ | |
45 | int | |
0cdcddb9 | 46 | etagParseInit(ETag * etag, const char *str) |
a9771e51 | 47 | { |
48 | int len; | |
49 | assert(etag && str); | |
50 | etag->str = NULL; | |
51 | etag->weak = !strncmp(str, "W/", 2); | |
62e76326 | 52 | |
a9771e51 | 53 | if (etag->weak) |
62e76326 | 54 | str += 2; |
55 | ||
a9771e51 | 56 | /* check format (quoted-string) */ |
57 | len = strlen(str); | |
62e76326 | 58 | |
0cdcddb9 | 59 | if (len >= 2 && str[0] == '"' && str[len - 1] == '"') |
62e76326 | 60 | etag->str = str; |
61 | ||
a9771e51 | 62 | return etag->str != NULL; |
63 | } | |
64 | ||
65 | /* returns true if etags are equal */ | |
66 | int | |
0cdcddb9 | 67 | etagIsEqual(const ETag * tag1, const ETag * tag2) |
a9771e51 | 68 | { |
69 | assert(tag1 && tag2); | |
0cdcddb9 | 70 | assert(!tag1->weak && !tag2->weak); /* weak comparison not implemented yet */ |
a9771e51 | 71 | return !strcmp(tag1->str, tag2->str); |
72 | } |