]>
Commit | Line | Data |
---|---|---|
450e0c10 | 1 | /* |
450e0c10 | 2 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
3 | * ---------------------------------------------------------- | |
4 | * | |
5 | * Squid is the result of efforts by numerous individuals from | |
6 | * the Internet community; see the CONTRIBUTORS file for full | |
7 | * details. Many organizations have provided support for Squid's | |
8 | * development; see the SPONSORS file for full details. Squid is | |
9 | * Copyrighted (C) 2001 by the Regents of the University of | |
10 | * California; see the COPYRIGHT file for full details. Squid | |
11 | * incorporates software developed and/or copyrighted by other | |
12 | * sources; see the CREDITS file for full details. | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License as published by | |
16 | * the Free Software Foundation; either version 2 of the License, or | |
17 | * (at your option) any later version. | |
26ac0430 | 18 | * |
450e0c10 | 19 | * This program is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
26ac0430 | 23 | * |
450e0c10 | 24 | * You should have received a copy of the GNU General Public License |
25 | * along with this program; if not, write to the Free Software | |
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
27 | * | |
28 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
29 | */ | |
450e0c10 | 30 | #ifndef SQUID_HTTPACCESSLOGENTRY_H |
31 | #define SQUID_HTTPACCESSLOGENTRY_H | |
32 | ||
33 | #include "HttpVersion.h" | |
75cb38cb | 34 | #include "HttpRequestMethod.h" |
b24880fe | 35 | #include "HierarchyLogEntry.h" |
96d89ea0 | 36 | #include "ip/Address.h" |
e1f7507e | 37 | #include "HttpRequestMethod.h" |
3ff65596 AR |
38 | #if ICAP_CLIENT |
39 | #include "adaptation/icap/Elements.h" | |
40 | #endif | |
450e0c10 | 41 | |
62ee09ca | 42 | /* forward decls */ |
e1f7507e AJ |
43 | class HttpReply; |
44 | class HttpRequest; | |
62ee09ca | 45 | |
450e0c10 | 46 | class AccessLogEntry |
47 | { | |
48 | ||
49 | public: | |
6fca33e0 | 50 | AccessLogEntry() : url(NULL) , reply(NULL), request(NULL), |
105d1937 | 51 | adapted_request(NULL) {} |
450e0c10 | 52 | |
53 | const char *url; | |
54 | ||
4e26d606 AJ |
55 | /** \brief This subclass holds log info for HTTP protocol |
56 | * \todo Inner class declarations should be moved outside | |
57 | * \todo details of HTTP held in the parent class need moving into here. | |
58 | */ | |
450e0c10 | 59 | class HttpDetails |
60 | { | |
61 | ||
62 | public: | |
307b696e A |
63 | HttpDetails() : method(METHOD_NONE), code(0), content_type(NULL), |
64 | timedout(false), aborted(false) {} | |
450e0c10 | 65 | |
60745f24 | 66 | HttpRequestMethod method; |
450e0c10 | 67 | int code; |
68 | const char *content_type; | |
69 | HttpVersion version; | |
f692498b AJ |
70 | bool timedout; ///< terminated due to a lifetime or I/O timeout |
71 | bool aborted; ///< other abnormal termination (e.g., I/O error) | |
72 | ||
73 | /// compute suffix for the status access.log field | |
74 | const char *statusSfx() const { | |
75 | return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : ""); | |
76 | } | |
2fadd50d | 77 | } http; |
450e0c10 | 78 | |
4e26d606 AJ |
79 | /** \brief This subclass holds log info for ICP protocol |
80 | * \todo Inner class declarations should be moved outside | |
81 | */ | |
82 | class IcpDetails | |
450e0c10 | 83 | { |
84 | ||
85 | public: | |
4e26d606 | 86 | IcpDetails() : opcode(ICP_INVALID) {} |
450e0c10 | 87 | |
88 | icp_opcode opcode; | |
2fadd50d | 89 | } icp; |
450e0c10 | 90 | |
4e26d606 AJ |
91 | /** \brief This subclass holds log info for HTCP protocol |
92 | * \todo Inner class declarations should be moved outside | |
93 | */ | |
04f7fd38 AJ |
94 | class HtcpDetails |
95 | { | |
a8b1cdf6 AJ |
96 | public: |
97 | HtcpDetails() : opcode(NULL) {}; | |
98 | ||
99 | const char *opcode; | |
100 | } htcp; | |
101 | ||
4e26d606 AJ |
102 | /** \brief This subclass holds log info for Squid internal stats |
103 | * \todo Inner class declarations should be moved outside | |
104 | * \todo some details relevant to particular protocols need shuffling to other sub-classes | |
105 | * \todo this object field need renaming to 'squid' or something. | |
106 | */ | |
450e0c10 | 107 | class CacheDetails |
108 | { | |
109 | ||
110 | public: | |
cc192b50 | 111 | CacheDetails() : caddr(), |
1a86db31 AJ |
112 | requestSize(0), |
113 | replySize(0), | |
3ff65596 AR |
114 | requestHeadersSize(0), |
115 | replyHeadersSize(0), | |
450e0c10 | 116 | highOffset(0), |
117 | objectSize(0), | |
118 | code (LOG_TAG_NONE), | |
119 | msec(0), | |
120 | rfc931 (NULL), | |
121 | authuser (NULL), | |
122 | extuser(NULL) | |
123 | #if USE_SSL | |
124 | ,ssluser(NULL) | |
125 | #endif | |
3d0ac046 | 126 | {; |
450e0c10 | 127 | } |
128 | ||
b7ac5457 | 129 | Ip::Address caddr; |
1a86db31 AJ |
130 | int64_t requestSize; |
131 | int64_t replySize; | |
3ff65596 AR |
132 | int requestHeadersSize; ///< received, including request line |
133 | int replyHeadersSize; ///< sent, including status line | |
47f6e231 | 134 | int64_t highOffset; |
135 | int64_t objectSize; | |
450e0c10 | 136 | log_type code; |
137 | int msec; | |
138 | const char *rfc931; | |
139 | const char *authuser; | |
661ef4eb | 140 | const char *extuser; |
450e0c10 | 141 | #if USE_SSL |
142 | ||
143 | const char *ssluser; | |
144 | #endif | |
145 | ||
2fadd50d | 146 | } cache; |
450e0c10 | 147 | |
4e26d606 AJ |
148 | /** \brief This subclass holds log info for various headers in raw format |
149 | * \todo shuffle this to the relevant protocol section. | |
150 | */ | |
450e0c10 | 151 | class Headers |
152 | { | |
153 | ||
154 | public: | |
3ff65596 | 155 | Headers() : request(NULL), |
105d1937 | 156 | adapted_request(NULL), |
6fca33e0 | 157 | |
3ff65596 | 158 | #if ICAP_CLIENT |
e1381638 | 159 | icap(NULL), |
3ff65596 | 160 | #endif |
e1381638 | 161 | reply(NULL) {} |
450e0c10 | 162 | |
6fca33e0 CT |
163 | char *request; //< virgin HTTP request headers |
164 | ||
105d1937 | 165 | char *adapted_request; //< HTTP request headers after adaptation and redirection |
6fca33e0 | 166 | |
3ff65596 AR |
167 | |
168 | #if ICAP_CLIENT | |
169 | char * icap; ///< last matching ICAP response header. | |
170 | #endif | |
450e0c10 | 171 | char *reply; |
2fadd50d | 172 | } headers; |
450e0c10 | 173 | |
e1f7507e AJ |
174 | // Why is this a sub-class and not a set of real "private:" fields? |
175 | // It looks like its duplicating HTTPRequestMethod anyway! | |
4e26d606 | 176 | // TODO: shuffle this to the relevant protocol section OR replace with request->method |
450e0c10 | 177 | class Private |
178 | { | |
179 | ||
180 | public: | |
181 | Private() : method_str(NULL) {} | |
182 | ||
183 | const char *method_str; | |
2fadd50d | 184 | } _private; |
450e0c10 | 185 | HierarchyLogEntry hier; |
186 | HttpReply *reply; | |
105d1937 | 187 | HttpRequest *request; //< virgin HTTP request |
6fca33e0 CT |
188 | HttpRequest *adapted_request; //< HTTP request after adaptation and redirection |
189 | ||
3ff65596 AR |
190 | |
191 | #if ICAP_CLIENT | |
192 | /** \brief This subclass holds log info for ICAP part of request | |
193 | * \todo Inner class declarations should be moved outside | |
194 | */ | |
e1381638 AJ |
195 | class IcapLogEntry |
196 | { | |
3ff65596 | 197 | public: |
bae917ac | 198 | IcapLogEntry():bodyBytesRead(-1),request(NULL),reply(NULL),outcome(Adaptation::Icap::xoUnknown),trTime(0),ioTime(0),resStatus(HTTP_STATUS_NONE) {} |
3ff65596 | 199 | |
b7ac5457 | 200 | Ip::Address hostAddr; ///< ICAP server IP address |
3ff65596 AR |
201 | String serviceName; ///< ICAP service name |
202 | String reqUri; ///< ICAP Request-URI | |
203 | Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method | |
204 | int64_t bytesSent; ///< number of bytes sent to ICAP server so far | |
205 | int64_t bytesRead; ///< number of bytes read from ICAP server so far | |
bae917ac CT |
206 | /** |
207 | * number of ICAP body bytes read from ICAP server or -1 for no encapsulated | |
208 | * message data in ICAP reply (eg 204 responses) | |
209 | */ | |
210 | int64_t bodyBytesRead; | |
3ff65596 AR |
211 | HttpRequest* request; ///< ICAP request |
212 | HttpReply* reply; ///< ICAP reply | |
213 | ||
214 | Adaptation::Icap::XactOutcome outcome; ///< final transaction status | |
215 | /** \brief Transaction response time. | |
216 | * The timer starts when the ICAP transaction | |
217 | * is created and stops when the result of the transaction is logged | |
218 | */ | |
219 | int trTime; | |
220 | /** \brief Transaction I/O time. | |
221 | * The timer starts when the first ICAP request | |
e1381638 | 222 | * byte is scheduled for sending and stops when the lastbyte of the |
3ff65596 AR |
223 | * ICAP response is received. |
224 | */ | |
225 | int ioTime; | |
226 | http_status resStatus; ///< ICAP response status code | |
227 | int processingTime; ///< total ICAP processing time in milliseconds | |
228 | } | |
229 | icap; | |
230 | #endif | |
450e0c10 | 231 | }; |
232 | ||
e1f7507e AJ |
233 | class ACLChecklist; |
234 | class StoreEntry; | |
235 | class logformat_token; | |
236 | ||
450e0c10 | 237 | /* Should be in 'AccessLog.h' as the driver */ |
3ff65596 | 238 | extern void accessLogLogTo(customlog* log, AccessLogEntry* al, ACLChecklist* checklist = NULL); |
62ee09ca | 239 | extern void accessLogLog(AccessLogEntry *, ACLChecklist * checklist); |
240 | extern void accessLogRotate(void); | |
241 | extern void accessLogClose(void); | |
242 | extern void accessLogInit(void); | |
62ee09ca | 243 | extern void accessLogFreeMemory(AccessLogEntry * aLogEntry); |
244 | extern const char *accessLogTime(time_t); | |
245 | extern int accessLogParseLogFormat(logformat_token ** fmt, char *def); | |
246 | extern void accessLogDumpLogFormat(StoreEntry * entry, const char *name, logformat * definitions); | |
247 | extern void accessLogFreeLogFormat(logformat_token ** fmt); | |
450e0c10 | 248 | |
249 | #endif /* SQUID_HTTPACCESSLOGENTRY_H */ |