From: Amos Jeffries Date: Thu, 23 Jun 2011 08:31:56 +0000 (-0600) Subject: SourceLayout: ETag and TimeOrTag in their own headers X-Git-Tag: take08~55^2~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81a94152232e2f41463390d4419f042bef9870ab;p=thirdparty%2Fsquid.git SourceLayout: ETag and TimeOrTag in their own headers --- diff --git a/src/ETag.cc b/src/ETag.cc index c845c52068..b2307b3fa2 100644 --- a/src/ETag.cc +++ b/src/ETag.cc @@ -33,7 +33,12 @@ * */ -#include "squid.h" +#include "config.h" +#include "ETag.h" + +#if HAVE_CSTRING +#include +#endif /* * Note: ETag is not an http "field" like, for example HttpHdrRange. ETag is a diff --git a/src/ETag.h b/src/ETag.h new file mode 100644 index 0000000000..0c3f1ae945 --- /dev/null +++ b/src/ETag.h @@ -0,0 +1,23 @@ +#ifndef _SQUID_ETAG_H +#define _SQUID_ETAG_H + +/** + * ETag support is rudimantal; this struct is likely to change + * Note: "str" points to memory in HttpHeaderEntry (for now) + * so ETags should be used as tmp variables only (for now) + */ +class ETag +{ +public: + const char *str; ///< quoted-string + int weak; ///< true if it is a weak validator +}; + +/* ETag */ +SQUIDCEXTERN int etagParseInit(ETag * etag, const char *str); +/// whether etags are strong-equal +SQUIDCEXTERN bool etagIsStrongEqual(const ETag &tag1, const ETag &tag2); +/// whether etags are weak-equal +SQUIDCEXTERN bool etagIsWeakEqual(const ETag &tag1, const ETag &tag2); + +#endif /* _SQUIDETAG_H */ diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 10bd05bb85..39cdc30943 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -42,6 +42,7 @@ #include "mgr/Registration.h" #include "rfc1123.h" #include "Store.h" +#include "TimeOrTag.h" /* * On naming conventions: diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 84fa95b12e..778b76fc1c 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -177,14 +177,6 @@ typedef ssize_t HttpHeaderPos; /* use this and only this to initialize HttpHeaderPos */ #define HttpHeaderInitPos (-1) -/* these two are defined in structs.h */ - -/// \todo CLEANUP: Kill this. -typedef struct _TimeOrTag TimeOrTag; - -/// \todo CLEANUP: Kill this. -typedef struct _ETag ETag; - class HttpHeaderEntry { @@ -204,6 +196,9 @@ public: MEMPROXY_CLASS_INLINE(HttpHeaderEntry); +class ETag; +class TimeOrTag; + class HttpHeader { diff --git a/src/Makefile.am b/src/Makefile.am index c65d35ac6f..6c152419ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -310,6 +310,7 @@ squid_SOURCES = \ errorpage.cc \ errorpage.h \ ETag.cc \ + ETag.h \ event.cc \ event.h \ EventLoop.h \ @@ -469,6 +470,7 @@ squid_SOURCES = \ SwapDir.cc \ SwapDir.h \ time.cc \ + TimeOrTag.h \ tools.cc \ tunnel.cc \ typedefs.h \ diff --git a/src/TimeOrTag.h b/src/TimeOrTag.h new file mode 100644 index 0000000000..b3449d9708 --- /dev/null +++ b/src/TimeOrTag.h @@ -0,0 +1,16 @@ +#ifndef _SQUID_TIMEORTAG_H +#define _SQUID_TIMEORTAG_H + +#include "ETag.h" + +/** + * Some fields can hold either time or etag specs (e.g. If-Range) + */ +class TimeOrTag { +public: + ETag tag; /* entity tag */ + time_t time; + int valid; /* true if struct is usable */ +}; + +#endif /* _SQUID_TIMEORTAG_H */ diff --git a/src/client_side.cc b/src/client_side.cc index 472ec928b2..85d545befb 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -129,6 +129,7 @@ #include "ssl/certificate_db.h" #endif #include "Store.h" +#include "TimeOrTag.h" #if HAVE_LIMITS #include diff --git a/src/errorpage.cc b/src/errorpage.cc index 7a6d7a683f..095bd2781c 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -39,6 +39,7 @@ #include "auth/UserRequest.h" #endif #include "SquidTime.h" +#include "ssl/ErrorDetailManager.h" #include "Store.h" #include "html_quote.h" #include "HttpReply.h" diff --git a/src/protos.h b/src/protos.h index c5a61794d5..446018f733 100644 --- a/src/protos.h +++ b/src/protos.h @@ -219,13 +219,6 @@ SQUIDCEXTERN int httpAnonHdrAllowed(http_hdr_type hdr_id); SQUIDCEXTERN int httpAnonHdrDenied(http_hdr_type hdr_id); SQUIDCEXTERN const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply); -/* ETag */ -SQUIDCEXTERN int etagParseInit(ETag * etag, const char *str); -/// whether etags are strong-equal -SQUIDCEXTERN bool etagIsStrongEqual(const ETag &tag1, const ETag &tag2); -/// whether etags are weak-equal -SQUIDCEXTERN bool etagIsWeakEqual(const ETag &tag1, const ETag &tag2); - #include "HttpStatusCode.h" SQUIDCEXTERN const char *httpStatusString(http_status status); diff --git a/src/store.cc b/src/store.cc index d574fecb91..94e382e663 100644 --- a/src/store.cc +++ b/src/store.cc @@ -36,6 +36,7 @@ #include "squid.h" #include "CacheManager.h" #include "comm/Connection.h" +#include "ETag.h" #include "event.h" #include "fde.h" #include "Store.h" diff --git a/src/structs.h b/src/structs.h index 38b978780f..c4b72debba 100644 --- a/src/structs.h +++ b/src/structs.h @@ -660,17 +660,6 @@ struct _dwrite_q { FREE *free_func; }; - -/* ETag support is rudimantal; - * this struct is likely to change - * Note: "str" points to memory in HttpHeaderEntry (for now) - * so ETags should be used as tmp variables only (for now) */ - -struct _ETag { - const char *str; /* quoted-string */ - int weak; /* true if it is a weak validator */ -}; - struct _fde_disk { DWCB *wrt_handle; void *wrt_handle_data; @@ -723,14 +712,6 @@ public: String other; }; -/* some fields can hold either time or etag specs (e.g. If-Range) */ - -struct _TimeOrTag { - ETag tag; /* entity tag */ - time_t time; - int valid; /* true if struct is usable */ -}; - /* per field statistics */ class HttpHeaderFieldStat diff --git a/src/typedefs.h b/src/typedefs.h index 8ef0b2bed5..ce065c35a8 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -60,14 +60,10 @@ typedef struct _dread_ctrl dread_ctrl; typedef struct _dwrite_q dwrite_q; -typedef struct _ETag ETag; - typedef struct _fileMap fileMap; typedef struct _HttpHeaderFieldAttrs HttpHeaderFieldAttrs; -typedef struct _TimeOrTag TimeOrTag; - typedef struct _HttpHeaderStat HttpHeaderStat; typedef struct _HttpBody HttpBody;