Revision: 14262
Author: adrian.chadd
Date: Tue Aug  4 09:20:22 2009
Log: Break out the location rewrite flow bits from the main client_side  
file and shove them into
a separate file.

This furthers my little goal of trimming down client_side to what is  
specifically related
to client_side handling and makes the control flow a little more obvious.


http://code.google.com/p/lusca-cache/source/detail?r=14262

Added:
  /branches/LUSCA_HEAD/src/client_side_location_rewrite.c
Modified:
  /branches/LUSCA_HEAD/src/Makefile.am
  /branches/LUSCA_HEAD/src/client_side.c
  /branches/LUSCA_HEAD/src/protos.h

=======================================
--- /dev/null
+++ /branches/LUSCA_HEAD/src/client_side_location_rewrite.c     Tue Aug  4  
09:20:22 2009
@@ -0,0 +1,103 @@
+
+/*
+ * $Id$
+ *
+ * DEBUG: section 33    Client-side Routines
+ * AUTHOR: Duane Wessels
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#include "squid.h"
+
+static void clientHttpLocationRewriteCheckDone(int answer, void *data);
+static void clientHttpLocationRewrite(clientHttpRequest * http);
+static void clientHttpLocationRewriteDone(void *data, char *reply);
+
+void
+clientHttpLocationRewriteCheck(clientHttpRequest * http)
+{
+    HttpReply *rep = http->reply;
+    aclCheck_t *ch;
+    if (!Config.Program.location_rewrite.command | 
| !httpHeaderHas(&rep->header, HDR_LOCATION)) {
+       clientHttpLocationRewriteDone(http, NULL);
+       return;
+    }
+    if (Config.accessList.location_rewrite) {
+       ch = clientAclChecklistCreate(Config.accessList.location_rewrite, http);
+       ch->reply = http->reply;
+       aclNBCheck(ch, clientHttpLocationRewriteCheckDone, http);
+    } else {
+       clientHttpLocationRewriteCheckDone(ACCESS_ALLOWED, http);
+    }
+}
+
+static void
+clientHttpLocationRewriteCheckDone(int answer, void *data)
+{
+    clientHttpRequest *http = data;
+    if (answer == ACCESS_ALLOWED) {
+       clientHttpLocationRewrite(http);
+    } else {
+       clientHttpLocationRewriteDone(http, NULL);
+    }
+}
+
+static void
+clientHttpLocationRewrite(clientHttpRequest * http)
+{
+    HttpReply *rep = http->reply;
+    if (!httpHeaderHas(&rep->header, HDR_LOCATION))
+       clientHttpLocationRewriteDone(http, NULL);
+    else
+       locationRewriteStart(rep, http, clientHttpLocationRewriteDone, http);
+}
+
+static void
+clientHttpLocationRewriteDone(void *data, char *reply)
+{
+    clientHttpRequest *http = data;
+    HttpReply *rep = http->reply;
+    ConnStateData *conn = http->conn;
+    if (reply && *reply) {
+       httpHeaderDelById(&rep->header, HDR_LOCATION);
+       if (*reply == '/') {
+           /* We have to restore the URL as sent by the client */
+           request_t *req = http->orig_request;
+           const char *proto = conn->port->protocol;
+           const char *host = httpHeaderGetStr(&req->header, HDR_HOST);
+           if (!host)
+               host = req->host;
+           httpHeaderPutStrf(&rep->header, HDR_LOCATION, "%s://%s%s", proto,  
host, reply);
+       } else {
+           httpHeaderPutStr(&rep->header, HDR_LOCATION, reply);
+       }
+    }
+    clientHttpReplyAccessCheck(http);
+}
+
=======================================
--- /branches/LUSCA_HEAD/src/Makefile.am        Wed Jul 22 07:37:20 2009
+++ /branches/LUSCA_HEAD/src/Makefile.am        Tue Aug  4 09:20:22 2009
@@ -127,6 +127,7 @@
        client_side.c \
        client_side_rewrite.c \
        client_side_storeurl_rewrite.c \
+       client_side_location_rewrite.c \
        comm.c \
        defines.h \
        $(DELAY_POOL_SOURCE) \
=======================================
--- /branches/LUSCA_HEAD/src/client_side.c      Thu Jul  9 03:21:46 2009
+++ /branches/LUSCA_HEAD/src/client_side.c      Tue Aug  4 09:20:22 2009
@@ -2854,11 +2854,6 @@
      }
  }

-static void clientHttpLocationRewriteCheck(clientHttpRequest * http);
-static void clientHttpLocationRewriteCheckDone(int answer, void *data);
-static void clientHttpLocationRewrite(clientHttpRequest * http);
-static void clientHttpLocationRewriteDone(void *data, char *reply);
-static void clientHttpReplyAccessCheck(clientHttpRequest * http);
  static void clientHttpReplyAccessCheckDone(int answer, void *data);
  static void clientCheckErrorMap(clientHttpRequest * http);
  static void clientCheckHeaderDone(clientHttpRequest * http);
@@ -2966,69 +2961,7 @@
      clientHttpLocationRewriteCheck(http);
  }

-static void
-clientHttpLocationRewriteCheck(clientHttpRequest * http)
-{
-    HttpReply *rep = http->reply;
-    aclCheck_t *ch;
-    if (!Config.Program.location_rewrite.command | 
| !httpHeaderHas(&rep->header, HDR_LOCATION)) {
-       clientHttpLocationRewriteDone(http, NULL);
-       return;
-    }
-    if (Config.accessList.location_rewrite) {
-       ch = clientAclChecklistCreate(Config.accessList.location_rewrite, http);
-       ch->reply = http->reply;
-       aclNBCheck(ch, clientHttpLocationRewriteCheckDone, http);
-    } else {
-       clientHttpLocationRewriteCheckDone(ACCESS_ALLOWED, http);
-    }
-}
-
-static void
-clientHttpLocationRewriteCheckDone(int answer, void *data)
-{
-    clientHttpRequest *http = data;
-    if (answer == ACCESS_ALLOWED) {
-       clientHttpLocationRewrite(http);
-    } else {
-       clientHttpLocationRewriteDone(http, NULL);
-    }
-}
-
-static void
-clientHttpLocationRewrite(clientHttpRequest * http)
-{
-    HttpReply *rep = http->reply;
-    if (!httpHeaderHas(&rep->header, HDR_LOCATION))
-       clientHttpLocationRewriteDone(http, NULL);
-    else
-       locationRewriteStart(rep, http, clientHttpLocationRewriteDone, http);
-}
-
-static void
-clientHttpLocationRewriteDone(void *data, char *reply)
-{
-    clientHttpRequest *http = data;
-    HttpReply *rep = http->reply;
-    ConnStateData *conn = http->conn;
-    if (reply && *reply) {
-       httpHeaderDelById(&rep->header, HDR_LOCATION);
-       if (*reply == '/') {
-           /* We have to restore the URL as sent by the client */
-           request_t *req = http->orig_request;
-           const char *proto = conn->port->protocol;
-           const char *host = httpHeaderGetStr(&req->header, HDR_HOST);
-           if (!host)
-               host = req->host;
-           httpHeaderPutStrf(&rep->header, HDR_LOCATION, "%s://%s%s", proto,  
host, reply);
-       } else {
-           httpHeaderPutStr(&rep->header, HDR_LOCATION, reply);
-       }
-    }
-    clientHttpReplyAccessCheck(http);
-}
-
-static void
+void
  clientHttpReplyAccessCheck(clientHttpRequest * http)
  {
      aclCheck_t *ch;
=======================================
--- /branches/LUSCA_HEAD/src/protos.h   Fri Jul 17 17:05:17 2009
+++ /branches/LUSCA_HEAD/src/protos.h   Tue Aug  4 09:20:22 2009
@@ -1071,6 +1071,7 @@
  extern int httpMsgFindHeadersEnd(HttpMsgBuf * hmsg);

  /* client_side.c */
+extern void clientHttpReplyAccessCheck(clientHttpRequest * http);      /* 
entry  
back into client_side.c from the location rewrite code */
  extern aclCheck_t *clientAclChecklistCreate(const acl_access * acl, const  
clientHttpRequest * http);
  extern void clientInterpretRequestHeaders(clientHttpRequest * http);
  extern void clientAccessCheck2(void *data);
@@ -1091,5 +1092,7 @@
  /* comm.c */
  extern void commConnectStart(int fd, const char *, u_short, CNCB *, void  
*, struct in_addr *addr);

+/* client_side_location_rewrite.c */
+extern void clientHttpLocationRewriteCheck(clientHttpRequest * http);

  #endif /* SQUID_PROTOS_H */

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to