From: Alex Rousskov Date: Fri, 11 Mar 2011 23:02:23 +0000 (-0700) Subject: SourceFormat: Moved Adaptation::Answer class to its dedicated source files. X-Git-Tag: take06~27^2~95 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1adcebc32aad6be10c480bee8730d57cb76c78b1;p=thirdparty%2Fsquid.git SourceFormat: Moved Adaptation::Answer class to its dedicated source files. --- diff --git a/src/Server.cc b/src/Server.cc index 66fd66ceb6..63292c70ad 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -47,6 +47,7 @@ #if USE_ADAPTATION #include "adaptation/AccessCheck.h" +#include "adaptation/Answer.h" #include "adaptation/Iterator.h" #endif diff --git a/src/Server.h b/src/Server.h index 1ec7acfd2d..c6b9b5c2df 100644 --- a/src/Server.h +++ b/src/Server.h @@ -45,6 +45,8 @@ #include "adaptation/Initiator.h" #endif +class HttpMsg; + /** * ServerStateData is a common base for server-side classes such as * HttpStateData and FtpStateData. All such classes must be able to diff --git a/src/adaptation/Answer.cc b/src/adaptation/Answer.cc new file mode 100644 index 0000000000..dc3daaccdf --- /dev/null +++ b/src/adaptation/Answer.cc @@ -0,0 +1,45 @@ +/* + * DEBUG: section 93 ICAP (RFC 3507) Client + */ + +#include "config.h" +#include "adaptation/Answer.h" +#include "base/AsyncJobCalls.h" + +Adaptation::Answer +Adaptation::Answer::Error(bool final) +{ + Answer answer(akError); + answer.final = final; + debugs(93, 4, HERE << "error: " << final); + return answer; +} + +Adaptation::Answer +Adaptation::Answer::Forward(HttpMsg *aMsg) +{ + Answer answer(akForward); + answer.message = aMsg; + debugs(93, 4, HERE << "forwarding: " << (void*)aMsg); + return answer; +} + + +Adaptation::Answer +Adaptation::Answer::Block(const String &aRule) +{ + Answer answer(akBlock); + answer.ruleId = aRule; + debugs(93, 4, HERE << "blocking rule: " << aRule); + return answer; +} + +std::ostream & +Adaptation::Answer::print(std::ostream &os) const +{ + return os << kind; // TODO: add more details +} + +Adaptation::Answer::Answer(Kind aKind): final(true), kind(aKind) +{ +} diff --git a/src/adaptation/Answer.h b/src/adaptation/Answer.h new file mode 100644 index 0000000000..cf7f71c983 --- /dev/null +++ b/src/adaptation/Answer.h @@ -0,0 +1,47 @@ +#ifndef SQUID_ADAPTATION__ANSWER_H +#define SQUID_ADAPTATION__ANSWER_H + +#include "adaptation/forward.h" +#include "HttpMsg.h" + +#include + +namespace Adaptation +{ + +/// summarizes adaptation service answer for the noteAdaptationAnswer() API +class Answer +{ +public: + /// helps interpret other members without a class hierarchy + typedef enum { + akForward, ///< forward the supplied adapted HTTP message + akBlock, ///< block or deny the master xaction; see authority + akError, ///< no adapted message will come; see bypassable + } Kind; + + static Answer Error(bool final); ///< create an akError answer + static Answer Forward(HttpMsg *aMsg); ///< create an akForward answer + static Answer Block(const String &aRule); ///< create an akBlock answer + + std::ostream &print(std::ostream &os) const; + +public: + HttpMsgPointerT message; ///< HTTP request or response to forward + String ruleId; ///< ACL (or similar rule) name that blocked forwarding + bool final; ///< whether the error, if any, cannot be bypassed + Kind kind; ///< the type of the answer + +private: + explicit Answer(Kind aKind); ///< use static creators instead +}; + +inline +std::ostream &operator <<(std::ostream &os, const Answer &answer) +{ + return answer.print(os); +} + +} // namespace Adaptation + +#endif /* SQUID_ADAPTATION__ANSWER_H */ diff --git a/src/adaptation/Initiate.cc b/src/adaptation/Initiate.cc index 7a0c3594ae..84a760f042 100644 --- a/src/adaptation/Initiate.cc +++ b/src/adaptation/Initiate.cc @@ -4,6 +4,7 @@ #include "squid.h" #include "HttpMsg.h" +#include "adaptation/Answer.h" #include "adaptation/Initiator.h" #include "adaptation/Initiate.h" #include "base/AsyncJobCalls.h" diff --git a/src/adaptation/Initiator.cc b/src/adaptation/Initiator.cc index 72805aee69..f72e69f8ea 100644 --- a/src/adaptation/Initiator.cc +++ b/src/adaptation/Initiator.cc @@ -28,46 +28,3 @@ Adaptation::Initiator::announceInitiatorAbort(CbcPointer &x) CallJobHere(93, 5, x, Initiate, noteInitiatorAborted); clearAdaptation(x); } - - -/* Adaptation::Answer */ - -// TODO: Move to src/adaptation/Answer.* - -Adaptation::Answer -Adaptation::Answer::Error(bool final) -{ - Answer answer(akError); - answer.final = final; - debugs(93, 4, HERE << "error: " << final); - return answer; -} - -Adaptation::Answer -Adaptation::Answer::Forward(HttpMsg *aMsg) -{ - Answer answer(akForward); - answer.message = aMsg; - debugs(93, 4, HERE << "forwarding: " << (void*)aMsg); - return answer; -} - - -Adaptation::Answer -Adaptation::Answer::Block(const String &aRule) -{ - Answer answer(akBlock); - answer.ruleId = aRule; - debugs(93, 4, HERE << "blocking rule: " << aRule); - return answer; -} - -std::ostream & -Adaptation::Answer::print(std::ostream &os) const -{ - return os << kind; // TODO: add more details -} - -Adaptation::Answer::Answer(Kind aKind): final(true), kind(aKind) -{ -} diff --git a/src/adaptation/Initiator.h b/src/adaptation/Initiator.h index 912f570897..59b817a3f8 100644 --- a/src/adaptation/Initiator.h +++ b/src/adaptation/Initiator.h @@ -1,12 +1,9 @@ #ifndef SQUID_ADAPTATION__INITIATOR_H #define SQUID_ADAPTATION__INITIATOR_H +#include "adaptation/forward.h" #include "base/AsyncJob.h" #include "base/CbcPointer.h" -#include "adaptation/forward.h" -#include "HttpMsg.h" - -#include /* * The ICAP Initiator is an ICAP vectoring point that initates ICAP @@ -20,39 +17,6 @@ namespace Adaptation { -/// summarizes adaptation service answer for the noteAdaptationAnswer() API -class Answer -{ -public: - /// helps interpret other members without a class hierarchy - typedef enum { - akForward, ///< forward the supplied adapted HTTP message - akBlock, ///< block or deny the master xaction; see authority - akError, ///< no adapted message will come; see bypassable - } Kind; - - static Answer Error(bool final); ///< create an akError answer - static Answer Forward(HttpMsg *aMsg); ///< create an akForward answer - static Answer Block(const String &aRule); ///< create an akBlock answer - - std::ostream &print(std::ostream &os) const; - -public: - HttpMsgPointerT message; ///< HTTP request or response to forward - String ruleId; ///< ACL (or similar rule) name that blocked forwarding - bool final; ///< whether the error, if any, cannot be bypassed - Kind kind; ///< the type of the answer - -private: - explicit Answer(Kind aKind); ///< use static creators instead -}; - -inline -std::ostream &operator <<(std::ostream &os, const Answer &answer) -{ - return answer.print(os); -} - class Initiator: virtual public AsyncJob { public: diff --git a/src/adaptation/Iterator.cc b/src/adaptation/Iterator.cc index 6982594348..4ca0301e4f 100644 --- a/src/adaptation/Iterator.cc +++ b/src/adaptation/Iterator.cc @@ -3,6 +3,7 @@ */ #include "squid.h" +#include "adaptation/Answer.h" #include "adaptation/Config.h" #include "adaptation/Iterator.h" #include "adaptation/Service.h" diff --git a/src/adaptation/Iterator.h b/src/adaptation/Iterator.h index 586532ac6e..c980edcf6d 100644 --- a/src/adaptation/Iterator.h +++ b/src/adaptation/Iterator.h @@ -5,6 +5,9 @@ #include "adaptation/Initiate.h" #include "adaptation/ServiceGroups.h" +class HttpMsg; +class HttpRequest; + namespace Adaptation { diff --git a/src/adaptation/Makefile.am b/src/adaptation/Makefile.am index b9466de778..03f2facbc3 100644 --- a/src/adaptation/Makefile.am +++ b/src/adaptation/Makefile.am @@ -20,6 +20,8 @@ libadaptation_la_SOURCES = \ AccessCheck.h \ AccessRule.cc \ AccessRule.h \ + Answer.cc \ + Answer.h \ Config.cc \ Config.h \ Elements.cc \ diff --git a/src/adaptation/ecap/XactionRep.cc b/src/adaptation/ecap/XactionRep.cc index 8349a2d6d3..f2a97267e2 100644 --- a/src/adaptation/ecap/XactionRep.cc +++ b/src/adaptation/ecap/XactionRep.cc @@ -10,6 +10,7 @@ #include "HttpRequest.h" #include "HttpReply.h" #include "SquidTime.h" +#include "adaptation/Answer.h" #include "adaptation/ecap/XactionRep.h" #include "adaptation/ecap/Config.h" #include "adaptation/Initiator.h" diff --git a/src/adaptation/icap/Launcher.cc b/src/adaptation/icap/Launcher.cc index 9ee142a08e..18a094edb5 100644 --- a/src/adaptation/icap/Launcher.cc +++ b/src/adaptation/icap/Launcher.cc @@ -4,6 +4,7 @@ #include "squid.h" #include "acl/FilledChecklist.h" +#include "adaptation/Answer.h" #include "adaptation/icap/Launcher.h" #include "adaptation/icap/Xaction.h" #include "adaptation/icap/ServiceRep.h" diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index ce4615e7fe..c2f11a2b25 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -4,6 +4,7 @@ #include "squid.h" #include "AccessLogEntry.h" +#include "adaptation/Answer.h" #include "adaptation/History.h" #include "adaptation/icap/Client.h" #include "adaptation/icap/Config.h" diff --git a/src/adaptation/icap/OptXact.cc b/src/adaptation/icap/OptXact.cc index 22971dc934..174feeb0c4 100644 --- a/src/adaptation/icap/OptXact.cc +++ b/src/adaptation/icap/OptXact.cc @@ -6,6 +6,7 @@ #include "comm.h" #include "HttpReply.h" +#include "adaptation/Answer.h" #include "adaptation/icap/OptXact.h" #include "adaptation/icap/Options.h" #include "adaptation/icap/Config.h" diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index a3faa9a2b1..9d2f90f743 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -3,6 +3,7 @@ */ #include "squid.h" +#include "adaptation/Answer.h" #include "adaptation/icap/Config.h" #include "adaptation/icap/ModXact.h" #include "adaptation/icap/Options.h" diff --git a/src/client_side_request.cc b/src/client_side_request.cc index e5110981bc..60290aec56 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -47,6 +47,7 @@ #include "acl/Gadgets.h" #if USE_ADAPTATION #include "adaptation/AccessCheck.h" +#include "adaptation/Answer.h" #include "adaptation/Iterator.h" #include "adaptation/Service.h" #if ICAP_CLIENT