/*
- * $Id: HttpHeader.cc,v 1.28 1998/03/31 17:52:08 rousskov Exp $
+ * $Id: HttpHeader.cc,v 1.29 1998/04/03 22:26:32 rousskov Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
return NULL; /* not reached */
}
+/*
+ * same as httpHeaderFindEntry
+ */
+static HttpHeaderEntry *
+httpHeaderFindLastEntry(const HttpHeader * hdr, http_hdr_type id)
+{
+ HttpHeaderPos pos = HttpHeaderInitPos;
+ HttpHeaderEntry *e;
+ HttpHeaderEntry *result = NULL;
+ assert(hdr);
+ assert_eid(id);
+ assert(!CBIT_TEST(ListHeadersMask, id));
+
+ debug(55, 8) ("finding entry %d in hdr %p\n", id, hdr);
+ /* check mask first */
+ if (!CBIT_TEST(hdr->mask, id))
+ return NULL;
+ /* looks like we must have it, do linear search */
+ while ((e = httpHeaderGetEntry(hdr, &pos))) {
+ if (e->id == id)
+ result = e;
+ }
+ assert(result); /* must be there! */
+ return result;
+}
+
/*
* deletes all fields with a given name if any, returns #fields deleted;
*/
return value;
}
+/* sync httpHeaderGetLastStr */
const char *
httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id)
{
return NULL;
}
+/* unusual */
+const char *
+httpHeaderGetLastStr(const HttpHeader * hdr, http_hdr_type id)
+{
+ HttpHeaderEntry *e;
+ assert_eid(id);
+ assert(Headers[id].type == ftStr); /* must be of an appropriate type */
+ if ((e = httpHeaderFindLastEntry(hdr, id))) {
+ httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
+ return strBuf(e->value);
+ }
+ return NULL;
+}
+
HttpHdrCc *
httpHeaderGetCc(const HttpHeader * hdr)
{
extern HttpHdrRange *httpHeaderGetRange(const HttpHeader * hdr);
extern HttpHdrContRange *httpHeaderGetContRange(const HttpHeader * hdr);
extern const char *httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id);
+extern const char *httpHeaderGetLastStr(const HttpHeader * hdr, http_hdr_type id);
extern int httpHeaderDelByName(HttpHeader * hdr, const char *name);
extern HttpHeaderEntry *httpHeaderFindEntry(const HttpHeader * hdr, http_hdr_type id);
extern void httpHeaderEntryPackInto(const HttpHeaderEntry * e, Packer * p);