/*
- * $Id: Server.cc,v 1.12 2007/06/19 20:58:26 rousskov Exp $
+ * $Id: Server.cc,v 1.13 2007/06/25 22:34:24 rousskov Exp $
*
* DEBUG:
* AUTHOR: Duane Wessels
#include "ICAP/ICAPModXact.h"
#endif
-ServerStateData::ServerStateData(FwdState *theFwdState): requestSender(NULL)
+ServerStateData::ServerStateData(FwdState *theFwdState): requestSender(NULL),
+ icapAccessCheckPending(false)
{
fwd = theFwdState;
entry = fwd->entry;
abortTransaction("ICAP failure");
}
+HttpRequest *
+ServerStateData::originalRequest()
+{
+ return request;
+}
+
+void
+ServerStateData::icapAclCheckDone(ICAPServiceRep::Pointer service)
+{
+ icapAccessCheckPending = false;
+
+ if (abortOnBadEntry("entry went bad while waiting for ICAP ACL check"))
+ return;
+
+ const bool startedIcap = startIcap(service, originalRequest());
+
+ if (!startedIcap && (!service || service->bypass)) {
+ // handle ICAP start failure when no service was selected
+ // or where the selected service was optional
+ entry->replaceHttpReply(reply);
+
+ haveParsedReplyHeaders();
+ processReplyBody();
+
+ return;
+ }
+
+ if (!startedIcap) {
+ // handle start failure for an essential ICAP service
+ ErrorState *err = errorCon(ERR_ICAP_FAILURE,
+ HTTP_INTERNAL_SERVER_ERROR, originalRequest());
+ err->xerrno = errno;
+ errorAppendEntry(entry, err);
+ abortTransaction("ICAP start failure");
+ return;
+ }
+
+ processReplyBody();
+}
+
#endif
/*
- * $Id: Server.h,v 1.4 2007/05/08 16:46:37 rousskov Exp $
+ * $Id: Server.h,v 1.5 2007/06/25 22:34:24 rousskov Exp $
*
* AUTHOR: Duane Wessels
*
virtual void abortTransaction(const char *reason) = 0;
#if ICAP_CLIENT
- virtual void icapAclCheckDone(ICAPServiceRep::Pointer) = 0;
+ void icapAclCheckDone(ICAPServiceRep::Pointer);
+ // a hack to reach HttpStateData::orignal_request
+ virtual HttpRequest *originalRequest();
// ICAPInitiator: start an ICAP transaction and receive adapted headers.
virtual void noteIcapAnswer(HttpMsg *message);
virtual void noteMoreBodySpaceAvailable(BodyPipe &);
virtual void noteBodyConsumerAborted(BodyPipe &);
#endif
+ virtual void processReplyBody() = 0;
public: // should be protected
void serverComplete(); // call when no server communication is expected
/*
- * $Id: ftp.cc,v 1.425 2007/06/19 20:27:00 rousskov Exp $
+ * $Id: ftp.cc,v 1.426 2007/06/25 22:34:24 rousskov Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
private:
// BodyConsumer for HTTP: consume request body.
virtual void handleRequestBodyProducerAborted();
-
-#if ICAP_CLIENT
-public:
- void icapAclCheckDone(ICAPServiceRep::Pointer);
-
- bool icapAccessCheckPending;
-#endif
-
};
CBDATA_CLASS_INIT(FtpStateData);
ftpState->icapAclCheckDone(service);
}
-// TODO: merge with http.cc and move to Server.cc?
-void
-FtpStateData::icapAclCheckDone(ICAPServiceRep::Pointer service)
-{
- icapAccessCheckPending = false;
-
- const bool startedIcap = startIcap(service, request);
-
- if (!startedIcap && (!service || service->bypass)) {
- // handle ICAP start failure when no service was selected
- // or where the selected service was optional
- entry->replaceHttpReply(reply);
- processReplyBody();
- return;
- }
-
- if (!startedIcap) {
- // handle start failure for an essential ICAP service
- ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
- err->xerrno = errno;
- errorAppendEntry(entry, err);
- comm_close(ctrl.fd);
- return;
- }
-
- processReplyBody();
-}
-
#endif
/*
- * $Id: http.cc,v 1.526 2007/06/19 21:19:04 rousskov Exp $
+ * $Id: http.cc,v 1.527 2007/06/25 22:34:24 rousskov Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
reply->sline.version = HttpVersion(1, 0);
reply->sline.status = status;
entry->replaceHttpReply(reply);
-
- if (eof == 1) {
- serverComplete();
- }
}
void
haveParsedReplyHeaders();
- if (eof == 1) {
- serverComplete();
- }
-
ctx_exit(ctx);
}
http->icapAclCheckDone(service);
}
-void
-HttpStateData::icapAclCheckDone(ICAPServiceRep::Pointer service)
+// TODO: why does FtpStateData not need orig_request?
+HttpRequest *
+HttpStateData::originalRequest()
{
- icapAccessCheckPending = false;
-
- const bool startedIcap = startIcap(service, orig_request);
-
- if (!startedIcap && (!service || service->bypass)) {
- // handle ICAP start failure when no service was selected
- // or where the selected service was optional
- entry->replaceHttpReply(reply);
-
- haveParsedReplyHeaders();
- processReplyBody();
-
- if (eof == 1)
- serverComplete();
-
- return;
- }
-
- if (!startedIcap) {
- // handle start failure for an essential ICAP service
- ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, orig_request);
- err->xerrno = errno;
- errorAppendEntry(entry, err);
- comm_close(fd);
- return;
- }
-
- processReplyBody();
+ return orig_request;
}
#endif
/*
- * $Id: http.h,v 1.28 2007/04/20 07:29:47 wessels Exp $
+ * $Id: http.h,v 1.29 2007/06/25 22:34:24 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
void processSurrogateControl(HttpReply *);
-#if ICAP_CLIENT
- void icapAclCheckDone(ICAPServiceRep::Pointer);
- bool icapAccessCheckPending;
-#endif
-
/*
* getReply() public only because it is called from a static function
* as httpState->getReply()
*/
const HttpReply * getReply() const { assert(reply); return reply; }
+protected:
+#if ICAP_CLIENT
+ virtual HttpRequest *originalRequest();
+#endif
+
private:
enum ConnectionStatus {
INCOMPLETE_MSG,