/*
- * $Id: HttpHeader.cc,v 1.126 2006/09/28 07:13:12 adrian Exp $
+ * $Id: HttpHeader.cc,v 1.127 2006/10/02 09:52:06 adrian Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
assert(p);
debug(55, 7) ("packing hdr: (%p)\n", this);
/* pack all entries one by one */
-
while ((e = getEntry(&pos)))
e->packInto(p);
+
+ /* Pack in the "special" entries */
+
+ /* Cache-Control */
}
/* returns next valid entry */
len += e->name.size() + 2 + e->value.size() + 2;
}
+bool
+HttpHeader::getList(http_hdr_type id, String *s) const
+{
+ HttpHeaderEntry *e;
+ HttpHeaderPos pos = HttpHeaderInitPos;
+ debug(55, 9) ("%p: joining for id %d\n", this, id);
+ /* only fields from ListHeaders array can be "listed" */
+ assert(CBIT_TEST(ListHeadersMask, id));
+
+ if (!CBIT_TEST(mask, id))
+ return false;
+
+ while ((e = getEntry(&pos))) {
+ if (e->id == id)
+ strListAdd(s, e->value.buf(), ',');
+ }
+
+ /*
+ * note: we might get an empty (size==0) string if there was an "empty"
+ * header. This results in an empty length String, which may have a NULL
+ * buffer.
+ */
+ /* temporary warning: remove it? (Is it useful for diagnostics ?) */
+ if (!s->size())
+ debugs(55, 3, "empty list header: " << Headers[id].name << "(" << id << ")");
+ else
+ debugs(55, 6, this << ": joined for id " << id << ": " << s);
+
+ return true;
+}
+
/* return a list of entries with the same id separated by ',' and ws */
String
HttpHeader::getList(http_hdr_type id) const
if (!CBIT_TEST(mask, HDR_CACHE_CONTROL))
return NULL;
+ PROF_start(HttpHeader_getCc);
- s = getList(HDR_CACHE_CONTROL);
+ getList(HDR_CACHE_CONTROL, &s);
cc = httpHdrCcParseCreate(&s);
httpHeaderNoteParsedEntry(HDR_CACHE_CONTROL, s, !cc);
- s.clean();
+ PROF_stop(HttpHeader_getCc);
return cc;
}
if (!CBIT_TEST(mask, HDR_SURROGATE_CONTROL))
return NULL;
- String s (getList(HDR_SURROGATE_CONTROL));
+ String s;
+
+ (void) getList(HDR_SURROGATE_CONTROL, &s);
HttpHdrSc *sc = httpHdrScParseCreate(&s);
{
if (has(HDR_CONNECTION)) {
/* anything that matches Connection list member will be deleted */
- String strConnection = getList(HDR_CONNECTION);
+ String strConnection;
+
+ (void) getList(HDR_CONNECTION, &strConnection);
const HttpHeaderEntry *e;
HttpHeaderPos pos = HttpHeaderInitPos;
/*
}
delById(HDR_CONNECTION);
- strConnection.clean();
}
}
/*
- * $Id: HttpHeader.h,v 1.17 2006/06/07 22:39:33 hno Exp $
+ * $Id: HttpHeader.h,v 1.18 2006/10/02 09:52:06 adrian Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
void addEntry(HttpHeaderEntry * e);
void insertEntry(HttpHeaderEntry * e);
String getList(http_hdr_type id) const;
+ bool getList(http_hdr_type id, String *s) const;
String getStrOrList(http_hdr_type id) const;
String getByName(const char *name) const;
String getByNameListMember(const char *name, const char *member, const char separator) const;