--------------------- PatchSet 10370 Date: 2008/01/05 11:46:56 Author: adri Branch: s27_adri Tag: (none) Log: Start breaking out the stuff httpHeaderParse() out into libhttp/. This is a precursor to writing a replacement header parser routine which uses string references. Members: libhttp/HttpHeader.c:1.1->1.1.2.1 libhttp/HttpHeader.h:1.1->1.1.2.1 libhttp/Makefile.am:1.1.2.1->1.1.2.2 src/enums.h:1.62.2.1.4.1->1.62.2.1.4.2 src/squid.h:1.36.24.11->1.36.24.12 src/structs.h:1.158.2.5.4.13->1.158.2.5.4.14 src/typedefs.h:1.43.2.3.4.7->1.43.2.3.4.8 tools/Makefile.am:1.3->1.3.26.1 tools/cossdump.c:1.5->1.5.28.1 --- /dev/null Sun Jan 6 01:23:40 2008 +++ squid/libhttp/HttpHeader.c Sun Jan 6 01:23:40 2008 @@ -0,0 +1,25 @@ + +/* + * $Id: HttpHeader.c,v 1.1.2.1 2008/01/05 11:46:56 adri Exp $ + */ + +#include +#include +#include +#include +#include +#include + +#include "../include/util.h" +#include "../include/Array.h" + +#include "../libcore/varargs.h" +#include "../libcore/debug.h" +#include "../libcore/tools.h" + +#include "../libbuf/buf.h" +#include "../libbuf/String.h" + +#include "HttpStrList.h" +#include "HttpHeader.h" + --- /dev/null Sun Jan 6 01:23:40 2008 +++ squid/libhttp/HttpHeader.h Sun Jan 6 01:23:40 2008 @@ -0,0 +1,113 @@ +#ifndef __LIBHTTP_HEADER_H__ +#define __LIBHTTP_HEADER_H__ + +/* recognized or "known" header fields; @?@ add more! */ +typedef enum { + HDR_UNKNOWN = -1, + HDR_ACCEPT = 0, + HDR_ACCEPT_CHARSET, + HDR_ACCEPT_ENCODING, + HDR_ACCEPT_LANGUAGE, + HDR_ACCEPT_RANGES, + HDR_AGE, + HDR_ALLOW, + HDR_AUTHORIZATION, + HDR_CACHE_CONTROL, + HDR_CONNECTION, + HDR_CONTENT_BASE, + HDR_CONTENT_DISPOSITION, + HDR_CONTENT_ENCODING, + HDR_CONTENT_LANGUAGE, + HDR_CONTENT_LENGTH, + HDR_CONTENT_LOCATION, + HDR_CONTENT_MD5, + HDR_CONTENT_RANGE, + HDR_CONTENT_TYPE, + HDR_TE, + HDR_TRANSFER_ENCODING, + HDR_TRAILER, + HDR_COOKIE, + HDR_DATE, + HDR_ETAG, + HDR_EXPIRES, + HDR_FROM, + HDR_HOST, + HDR_IF_MATCH, + HDR_IF_MODIFIED_SINCE, + HDR_IF_NONE_MATCH, + HDR_IF_RANGE, + HDR_LAST_MODIFIED, + HDR_LINK, + HDR_LOCATION, + HDR_MAX_FORWARDS, + HDR_MIME_VERSION, + HDR_PRAGMA, + HDR_PROXY_AUTHENTICATE, + HDR_PROXY_AUTHENTICATION_INFO, + HDR_PROXY_AUTHORIZATION, + HDR_PROXY_CONNECTION, + HDR_PUBLIC, + HDR_RANGE, + HDR_REQUEST_RANGE, /* some clients use this, sigh */ + HDR_REFERER, + HDR_RETRY_AFTER, + HDR_SERVER, + HDR_SET_COOKIE, + HDR_UPGRADE, + HDR_USER_AGENT, + HDR_VARY, + HDR_VIA, + HDR_EXPECT, + HDR_WARNING, + HDR_WWW_AUTHENTICATE, + HDR_AUTHENTICATION_INFO, + HDR_X_CACHE, + HDR_X_CACHE_LOOKUP, /* tmp hack, remove later */ + HDR_X_FORWARDED_FOR, + HDR_X_REQUEST_URI, /* appended if ADD_X_REQUEST_URI is #defined */ + HDR_X_SQUID_ERROR, + HDR_NEGOTIATE, +#if X_ACCELERATOR_VARY + HDR_X_ACCELERATOR_VARY, +#endif + HDR_X_ERROR_URL, /* errormap, requested URL */ + HDR_X_ERROR_STATUS, /* errormap, received HTTP status line */ + HDR_FRONT_END_HTTPS, + HDR_PROXY_SUPPORT, + HDR_KEEP_ALIVE, + HDR_OTHER, + HDR_ENUM_END +} http_hdr_type; + +typedef char HttpHeaderMask[(HDR_ENUM_END + 7) / 8]; + +/* possible owners of http header */ +typedef enum { + hoNone, +#if USE_HTCP + hoHtcpReply, +#endif + hoRequest, + hoReply +} http_hdr_owner_type; + +struct _HttpHeaderEntry { + http_hdr_type id; + int active; + String name; + String value; +}; + +struct _HttpHeader { + /* protected, do not use these, use interface functions instead */ + Array entries; /* parsed entries in raw format */ + HttpHeaderMask mask; /* bit set <=> entry present */ + http_hdr_owner_type owner; /* request or reply */ + int len; /* length when packed, not counting terminating '\0' */ +}; + +typedef struct _HttpHeader HttpHeader; +typedef struct _HttpHeaderEntry HttpHeaderEntry; + + +#endif Index: squid/libhttp/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/libhttp/Attic/Makefile.am,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/libhttp/Makefile.am 17 Dec 2007 08:17:47 -0000 1.1.2.1 +++ squid/libhttp/Makefile.am 5 Jan 2008 11:46:57 -0000 1.1.2.2 @@ -1,13 +1,15 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.1.2.1 2007/12/17 08:17:47 adri Exp $ +# $Id: Makefile.am,v 1.1.2.2 2008/01/05 11:46:57 adri Exp $ # libhttp_a_SOURCES = \ - HttpStrList.c + HttpStrList.c \ + HttpHeader.c libhttp_a_LIBADD = \ - HttpStrList.o + HttpStrList.o \ + HttpHeader.o noinst_LIBRARIES = \ libhttp.a Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.62.2.1.4.1 retrieving revision 1.62.2.1.4.2 diff -u -r1.62.2.1.4.1 -r1.62.2.1.4.2 --- squid/src/enums.h 22 Dec 2007 14:32:11 -0000 1.62.2.1.4.1 +++ squid/src/enums.h 5 Jan 2008 11:46:57 -0000 1.62.2.1.4.2 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.62.2.1.4.1 2007/12/22 14:32:11 adri Exp $ + * $Id: enums.h,v 1.62.2.1.4.2 2008/01/05 11:46:57 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -189,84 +189,6 @@ LOOKUP_MISS } lookup_t; -/* recognized or "known" header fields; @?@ add more! */ -typedef enum { - HDR_UNKNOWN = -1, - HDR_ACCEPT = 0, - HDR_ACCEPT_CHARSET, - HDR_ACCEPT_ENCODING, - HDR_ACCEPT_LANGUAGE, - HDR_ACCEPT_RANGES, - HDR_AGE, - HDR_ALLOW, - HDR_AUTHORIZATION, - HDR_CACHE_CONTROL, - HDR_CONNECTION, - HDR_CONTENT_BASE, - HDR_CONTENT_DISPOSITION, - HDR_CONTENT_ENCODING, - HDR_CONTENT_LANGUAGE, - HDR_CONTENT_LENGTH, - HDR_CONTENT_LOCATION, - HDR_CONTENT_MD5, - HDR_CONTENT_RANGE, - HDR_CONTENT_TYPE, - HDR_TE, - HDR_TRANSFER_ENCODING, - HDR_TRAILER, - HDR_COOKIE, - HDR_DATE, - HDR_ETAG, - HDR_EXPIRES, - HDR_FROM, - HDR_HOST, - HDR_IF_MATCH, - HDR_IF_MODIFIED_SINCE, - HDR_IF_NONE_MATCH, - HDR_IF_RANGE, - HDR_LAST_MODIFIED, - HDR_LINK, - HDR_LOCATION, - HDR_MAX_FORWARDS, - HDR_MIME_VERSION, - HDR_PRAGMA, - HDR_PROXY_AUTHENTICATE, - HDR_PROXY_AUTHENTICATION_INFO, - HDR_PROXY_AUTHORIZATION, - HDR_PROXY_CONNECTION, - HDR_PUBLIC, - HDR_RANGE, - HDR_REQUEST_RANGE, /* some clients use this, sigh */ - HDR_REFERER, - HDR_RETRY_AFTER, - HDR_SERVER, - HDR_SET_COOKIE, - HDR_UPGRADE, - HDR_USER_AGENT, - HDR_VARY, - HDR_VIA, - HDR_EXPECT, - HDR_WARNING, - HDR_WWW_AUTHENTICATE, - HDR_AUTHENTICATION_INFO, - HDR_X_CACHE, - HDR_X_CACHE_LOOKUP, /* tmp hack, remove later */ - HDR_X_FORWARDED_FOR, - HDR_X_REQUEST_URI, /* appended if ADD_X_REQUEST_URI is #defined */ - HDR_X_SQUID_ERROR, - HDR_NEGOTIATE, -#if X_ACCELERATOR_VARY - HDR_X_ACCELERATOR_VARY, -#endif - HDR_X_ERROR_URL, /* errormap, requested URL */ - HDR_X_ERROR_STATUS, /* errormap, received HTTP status line */ - HDR_FRONT_END_HTTPS, - HDR_PROXY_SUPPORT, - HDR_KEEP_ALIVE, - HDR_OTHER, - HDR_ENUM_END -} http_hdr_type; - typedef enum { CC_PUBLIC, CC_PRIVATE, @@ -299,16 +221,6 @@ ftSize } field_type; -/* possible owners of http header */ -typedef enum { - hoNone, -#if USE_HTCP - hoHtcpReply, -#endif - hoRequest, - hoReply -} http_hdr_owner_type; - typedef enum { HIER_NONE, HIER_DIRECT, Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.36.24.11 retrieving revision 1.36.24.12 diff -u -r1.36.24.11 -r1.36.24.12 --- squid/src/squid.h 5 Jan 2008 09:42:41 -0000 1.36.24.11 +++ squid/src/squid.h 5 Jan 2008 11:46:57 -0000 1.36.24.12 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.36.24.11 2008/01/05 09:42:41 adri Exp $ + * $Id: squid.h,v 1.36.24.12 2008/01/05 11:46:57 adri Exp $ * * AUTHOR: Duane Wessels * @@ -393,6 +393,7 @@ /* libhttp */ #include "../libhttp/HttpStrList.h" +#include "../libhttp/HttpHeader.h" /* Needed for poll() on Linux at least */ #if USE_POLL Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.158.2.5.4.13 retrieving revision 1.158.2.5.4.14 diff -u -r1.158.2.5.4.13 -r1.158.2.5.4.14 --- squid/src/structs.h 5 Jan 2008 09:42:42 -0000 1.158.2.5.4.13 +++ squid/src/structs.h 5 Jan 2008 11:46:57 -0000 1.158.2.5.4.14 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.158.2.5.4.13 2008/01/05 09:42:42 adri Exp $ + * $Id: structs.h,v 1.158.2.5.4.14 2008/01/05 11:46:57 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1053,21 +1053,6 @@ HttpHeaderFieldStat stat; }; -struct _HttpHeaderEntry { - http_hdr_type id; - int active; - String name; - String value; -}; - -struct _HttpHeader { - /* protected, do not use these, use interface functions instead */ - Array entries; /* parsed entries in raw format */ - HttpHeaderMask mask; /* bit set <=> entry present */ - http_hdr_owner_type owner; /* request or reply */ - int len; /* length when packed, not counting terminating '\0' */ -}; - struct _HttpReply { /* unsupported, writable, may disappear/change in the future */ int hdr_sz; /* sums _stored_ status-line, headers, and */ Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.43.2.3.4.7 retrieving revision 1.43.2.3.4.8 diff -u -r1.43.2.3.4.7 -r1.43.2.3.4.8 --- squid/src/typedefs.h 5 Jan 2008 09:42:42 -0000 1.43.2.3.4.7 +++ squid/src/typedefs.h 5 Jan 2008 11:46:57 -0000 1.43.2.3.4.8 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.43.2.3.4.7 2008/01/05 09:42:42 adri Exp $ + * $Id: typedefs.h,v 1.43.2.3.4.8 2008/01/05 11:46:57 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -127,14 +127,12 @@ typedef struct _HttpStatusLine HttpStatusLine; typedef struct _HttpHeaderFieldAttrs HttpHeaderFieldAttrs; typedef struct _HttpHeaderFieldInfo HttpHeaderFieldInfo; -typedef struct _HttpHeader HttpHeader; typedef struct _HttpHdrCc HttpHdrCc; typedef struct _HttpHdrRangeSpec HttpHdrRangeSpec; typedef struct _HttpHdrRange HttpHdrRange; typedef struct _HttpHdrRangeIter HttpHdrRangeIter; typedef struct _HttpHdrContRange HttpHdrContRange; typedef struct _TimeOrTag TimeOrTag; -typedef struct _HttpHeaderEntry HttpHeaderEntry; typedef struct _HttpHeaderFieldStat HttpHeaderFieldStat; typedef struct _HttpHeaderStat HttpHeaderStat; typedef struct _HttpBody HttpBody; @@ -379,9 +377,6 @@ /*iteration for headers; use HttpHeaderPos as opaque type, do not interpret */ typedef int HttpHeaderPos; -/* big mask for http headers */ -typedef char HttpHeaderMask[(HDR_ENUM_END + 7) / 8]; - /* a common objPackInto interface; used by debugObj */ typedef void (*ObjPackMethod) (void *obj, Packer * p); Index: squid/tools/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/tools/Makefile.am,v retrieving revision 1.3 retrieving revision 1.3.26.1 diff -u -r1.3 -r1.3.26.1 --- squid/tools/Makefile.am 22 Sep 2006 09:52:58 -0000 1.3 +++ squid/tools/Makefile.am 5 Jan 2008 11:46:57 -0000 1.3.26.1 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.3 2006/09/22 09:52:58 squidadm Exp $ +# $Id: Makefile.am,v 1.3.26.1 2008/01/05 11:46:57 adri Exp $ # # Uncomment and customize the following to suit your needs: # @@ -34,7 +34,7 @@ cachemgr__CGIEXT__SOURCES = cachemgr.c cachemgr__CGIEXT__CFLAGS = -DDEFAULT_CACHEMGR_CONFIG=\"$(DEFAULT_CACHEMGR_CONFIG)\" $(AM_CFLAGS) -LDADD = -L../lib -lmiscutil $(XTRA_LIBS) +LDADD = -L../lib -L../libcore -L../libbuf -L../libmem -L../libhttp -lcore -lbuf -lmem -lhttp -lmiscutil $(XTRA_LIBS) EXTRA_DIST = \ cachemgr.conf Index: squid/tools/cossdump.c =================================================================== RCS file: /cvsroot/squid-sf//squid/tools/cossdump.c,v retrieving revision 1.5 retrieving revision 1.5.28.1 diff -u -r1.5 -r1.5.28.1 --- squid/tools/cossdump.c 4 Sep 2006 01:51:54 -0000 1.5 +++ squid/tools/cossdump.c 5 Jan 2008 11:46:57 -0000 1.5.28.1 @@ -12,9 +12,6 @@ #if HAVE_UNISTD_H #include #endif -#if HAVE_ASSERT_H -#include -#endif #if HAVE_STRING_H #include #endif @@ -25,6 +22,20 @@ #include #endif +#include "../include/util.h" +#include "../include/Array.h" + +#include "../libcore/varargs.h" +#include "../libcore/debug.h" +#include "../libcore/tools.h" + +#include "../libbuf/buf.h" +#include "../libbuf/String.h" + +#include "../libhttp/HttpStrList.h" +#include "../libhttp/HttpHeader.h" + + #include "../src/defines.h" #include "../src/enums.h" @@ -69,6 +80,9 @@ #define strto_off_t strtol #endif +int squid_curtime; +int shutting_down; + static tlv ** storeSwapTLVAdd(int type, const void *ptr, size_t len, tlv ** tail) {