#ifndef SQUID_ICAPXACTION_H
#define SQUID_ICAPXACTION_H
-#include "comm.h"
+#include "comm/forward.h"
#include "CommCalls.h"
#include "MemBuf.h"
#include "adaptation/icap/ServiceRep.h"
#include "adaptation/Initiate.h"
+#include "AccessLogEntry.h"
+#include "HttpReply.h"
+#include "ipcache.h"
-class HttpMsg;
class CommConnectCbParams;
-namespace Adaptation {
-namespace Icap {
+namespace Adaptation
+{
+namespace Icap
+{
/*
* The ICAP Xaction implements common tasks for ICAP OPTIONS, REQMOD, and
{
public:
- Xaction(const char *aTypeName, Adaptation::Initiator *anInitiator, ServiceRep::Pointer &aService);
+ Xaction(const char *aTypeName, ServiceRep::Pointer &aService);
virtual ~Xaction();
void disableRetries();
+ void disableRepeats(const char *reason);
+ bool retriable() const { return isRetriable; }
+ bool repeatable() const { return isRepeatable; }
// comm handler wrappers, treat as private
void noteCommConnected(const CommConnectCbParams &io);
void noteCommTimedout(const CommTimeoutCbParams &io);
void noteCommClosed(const CommCloseCbParams &io);
+ // TODO: create these only when actually sending/receiving
+ HttpRequest *icapRequest; ///< sent (or at least created) ICAP request
+ HttpReply::Pointer icapReply; ///< received ICAP reply, if any
+
+ /// the number of times we tried to get to the service, including this time
+ int attempts;
+
protected:
virtual void start();
virtual void noteInitiatorAborted(); // TODO: move to Adaptation::Initiate
virtual void handleCommTimedout();
virtual void handleCommClosed();
+ /// record error detail if possible
+ virtual void detailError(int errDetail) {}
+
void openConnection();
void closeConnection();
void dieOnConnectionFailure();
+ bool haveConnection() const;
void scheduleRead();
void scheduleWrite(MemBuf &buf);
// useful for debugging
virtual bool fillVirginHttpHeader(MemBuf&) const;
- // custom end-of-call checks
+public:
+ // custom exception handling and end-of-call checks
+ virtual void callException(const std::exception &e);
virtual void callEnd();
+ /// clear stored error details, if any; used for retries/repeats
+ virtual void clearError() {}
+ void dnsLookupDone(const ipcache_addrs *ia);
+
+protected:
+ // logging
+ void setOutcome(const XactOutcome &xo);
+ virtual void finalizeLogInfo();
+public:
ServiceRep &service();
+private:
+ void tellQueryAborted();
+ void maybeLog();
+
protected:
- int connection; // FD of the ICAP server connection
+ Comm::ConnectionPointer connection; ///< ICAP server connection
+ Adaptation::Icap::ServiceRep::Pointer theService;
/*
* We have two read buffers. We would prefer to read directly
size_t commBufSize;
bool commEof;
bool reuseConnection;
- bool isRetriable;
+ bool isRetriable; ///< can retry on persistent connection failures
+ bool isRepeatable; ///< can repeat if no or unsatisfactory response
bool ignoreLastWrite;
const char *stopReason;
AsyncCall::Pointer writer;
AsyncCall::Pointer closer;
+ AccessLogEntry::Pointer alep; ///< icap.log entry
+ AccessLogEntry &al; ///< short for *alep
+
+ timeval icap_tr_start; /*time when the ICAP transaction was created */
+ timeval icap_tio_start; /*time when the first ICAP request byte was scheduled for sending*/
+ timeval icap_tio_finish; /*time when the last byte of the ICAP responsewas received*/
+
private:
//CBDATA_CLASS2(Xaction);
};
-
} // namespace Icap
} // namespace Adaptation