]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpHdrScTarget.cc
5 * DEBUG: section 90 HTTP Cache Control Header
6 * AUTHOR: Alex Rousskov
7 * Robert Collins (Surrogate-Control is derived from
10 * SQUID Web Proxy Cache http://www.squid-cache.org/
11 * ----------------------------------------------------------
13 * Squid is the result of efforts by numerous individuals from
14 * the Internet community; see the CONTRIBUTORS file for full
15 * details. Many organizations have provided support for Squid's
16 * development; see the SPONSORS file for full details. Squid is
17 * Copyrighted (C) 2001 by the Regents of the University of
18 * California; see the COPYRIGHT file for full details. Squid
19 * incorporates software developed and/or copyrighted by other
20 * sources; see the CREDITS file for full details.
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
39 #include "HttpHdrSc.h"
41 /* local prototypes */
43 /* module initialization */
48 httpHdrScTargetCreate(char const *target
)
50 HttpHdrScTarget
*sc
= new HttpHdrScTarget();
52 /* max_stale is specified as 0 if not specified in the header */
58 httpHdrScTargetDestroy(HttpHdrScTarget
* sc
)
67 httpHdrScTargetDup(const HttpHdrScTarget
* sc
)
71 dup
= httpHdrScTargetCreate(sc
->target
.buf());
73 dup
->max_age
= sc
->max_age
;
74 dup
->content
= sc
->content
;
78 /* union of two targets */
80 httpHdrScTargetJoinWith(HttpHdrScTarget
* sc
, const HttpHdrScTarget
* new_sc
)
83 /* TODO: check both targets are the same */
86 sc
->max_age
= new_sc
->max_age
;
88 if (sc
->max_stale
< new_sc
->max_stale
)
89 sc
->max_stale
= new_sc
->max_stale
;
91 /* RC TODO: copy unique missing content stringlist entries */
92 sc
->mask
|= new_sc
->mask
;
95 extern http_hdr_sc_type
&operator++ (http_hdr_sc_type
&aHeader
);
96 extern int operator - (http_hdr_sc_type
const &anSc
, http_hdr_sc_type
const &anSc2
);
97 /* copies non-extant fields from new_sc to this sc */
99 httpHdrScTargetMergeWith(HttpHdrScTarget
* sc
, const HttpHdrScTarget
* new_sc
)
102 assert(sc
&& new_sc
);
103 /* Don't touch the target - this is used to get the operations for a
107 for (c
= SC_NO_STORE
; c
< SC_ENUM_END
; ++c
)
108 if (!EBIT_TEST(sc
->mask
, c
) && EBIT_TEST(new_sc
->mask
,c
)) {
109 EBIT_SET(sc
->mask
, c
);
114 sc
->max_age
= new_sc
->max_age
;
115 sc
->max_stale
= new_sc
->max_stale
;
119 assert (sc
->content
.size() == 0);
120 sc
->content
= new_sc
->content
;
129 /* negative max_age will clean old max_Age setting */
131 httpHdrScTargetSetMaxAge(HttpHdrScTarget
* sc
, int max_age
)
134 sc
->max_age
= max_age
;
137 EBIT_SET(sc
->mask
, SC_MAX_AGE
);
139 EBIT_CLR(sc
->mask
, SC_MAX_AGE
);
143 httpHdrScTargetUpdateStats(const HttpHdrScTarget
* sc
, StatHist
* hist
)
148 for (c
= SC_NO_STORE
; c
< SC_ENUM_END
; ++c
)
149 if (EBIT_TEST(sc
->mask
, c
))
150 statHistCount(hist
, c
);