/*
- * $Id: Array.h,v 1.21 2005/04/30 19:32:01 serassio Exp $
+ * $Id: Array.h,v 1.22 2005/06/09 07:07:30 hno Exp $
*
* AUTHOR: Alex Rousskov
*
void clean();
void reserve (size_t capacity);
void push_back (E);
+ Vector &operator += (E item) {push_back(item);};
+ void insert (E);
E &back();
E pop_back();
void preAppend(int app_count);
items[count++] = obj;
}
+template<class E>
+void
+Vector<E>::insert(E obj)
+{
+ if (size() >= capacity)
+ reserve (size() + 1);
+
+ int i;
+ for (i = count; i > 0; i--)
+ items[i] = items[i - 1];
+
+ items[i] = obj;
+ count += 1;
+}
+
template<class E>
E
Vector<E>::pop_back()
/*
- * $Id: HttpHeader.cc,v 1.105 2005/05/28 20:01:06 serassio Exp $
+ * $Id: HttpHeader.cc,v 1.106 2005/06/09 07:07:30 hno Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
hdr->len += e->name.size() + 2 + e->value.size() + 2;
}
+/* inserts an entry;
+ * does not call httpHeaderEntryClone() so one should not reuse "*e"
+ */
+void
+httpHeaderInsertEntry(HttpHeader * hdr, HttpHeaderEntry * e)
+{
+ assert(hdr && e);
+ assert_eid(e->id);
+
+ debugs(55, 7, hdr << " adding entry: " << e->id << " at " <<
+ hdr->entries.count);
+
+ if (CBIT_TEST(hdr->mask, e->id))
+ Headers[e->id].stat.repCount++;
+ else
+ CBIT_SET(hdr->mask, e->id);
+
+ hdr->entries.insert(e);
+
+ /* increment header length, allow for ": " and crlf */
+ hdr->len += e->name.size() + 2 + e->value.size() + 2;
+}
+
/* return a list of entries with the same id separated by ',' and ws */
String
httpHeaderGetList(const HttpHeader * hdr, http_hdr_type id)
httpHeaderAddEntry(hdr, httpHeaderEntryCreate(id, NULL, mkrfc1123(htime)));
}
+void
+httpHeaderInsertTime(HttpHeader * hdr, http_hdr_type id, time_t htime)
+{
+ assert_eid(id);
+ assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
+ assert(htime >= 0);
+ httpHeaderInsertEntry(hdr, httpHeaderEntryCreate(id, NULL, mkrfc1123(htime)));
+}
+
void
httpHeaderPutStr(HttpHeader * hdr, http_hdr_type id, const char *str)
{
/*
- * $Id: client_side_reply.cc,v 1.83 2005/04/18 21:52:42 hno Exp $
+ * $Id: client_side_reply.cc,v 1.84 2005/06/09 07:07:30 hno Exp $
*
* DEBUG: section 88 Client-side Reply Routines
* AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
(void) 0;
else if (http->storeEntry()->timestamp < 0)
(void) 0;
- else if (http->storeEntry()->timestamp < squid_curtime) {
+
+ if (EBIT_TEST(http->storeEntry()->flags, ENTRY_SPECIAL)) {
+ httpHeaderDelById(hdr, HDR_DATE);
+ httpHeaderInsertTime(hdr, HDR_DATE, squid_curtime);
+ } else if (http->storeEntry()->timestamp < squid_curtime) {
httpHeaderPutInt(hdr, HDR_AGE,
squid_curtime - http->storeEntry()->timestamp);
/* Signal old objects. NB: rfc 2616 is not clear,
/*
- * $Id: protos.h,v 1.505 2005/04/18 21:52:43 hno Exp $
+ * $Id: protos.h,v 1.506 2005/06/09 07:07:30 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
SQUIDCEXTERN int httpHeaderHas(const HttpHeader * hdr, http_hdr_type type);
SQUIDCEXTERN void httpHeaderPutInt(HttpHeader * hdr, http_hdr_type type, int number);
SQUIDCEXTERN void httpHeaderPutTime(HttpHeader * hdr, http_hdr_type type, time_t htime);
+SQUIDCEXTERN void httpHeaderInsertTime(HttpHeader * hdr, http_hdr_type type, time_t htime);
SQUIDCEXTERN void httpHeaderPutStr(HttpHeader * hdr, http_hdr_type type, const char *str);
SQUIDCEXTERN void httpHeaderPutAuth(HttpHeader * hdr, const char *auth_scheme, const char *realm);
SQUIDCEXTERN void httpHeaderPutCc(HttpHeader * hdr, const HttpHdrCc * cc);
SQUIDCEXTERN HttpHeaderEntry *httpHeaderGetEntry(const HttpHeader * hdr, HttpHeaderPos * pos);
SQUIDCEXTERN HttpHeaderEntry *httpHeaderFindEntry(const HttpHeader * hdr, http_hdr_type id);
SQUIDCEXTERN void httpHeaderAddEntry(HttpHeader * hdr, HttpHeaderEntry * e);
+SQUIDCEXTERN void httpHeaderInsertEntry(HttpHeader * hdr, HttpHeaderEntry * e);
SQUIDCEXTERN HttpHeaderEntry *httpHeaderEntryClone(const HttpHeaderEntry * e);
SQUIDCEXTERN void httpHeaderEntryPackInto(const HttpHeaderEntry * e, Packer * p);
/* store report about current header usage and other stats */