]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed an ICAP bug: Need to handle the case when a REQMOD reply
authorwessels <>
Wed, 21 Dec 2005 06:22:29 +0000 (06:22 +0000)
committerwessels <>
Wed, 21 Dec 2005 06:22:29 +0000 (06:22 +0000)
doesn't have any new HTTP headers.

src/ICAP/ICAPClientReqmodPrecache.cc
src/ICAP/ICAPModXact.cc
src/client_side_request.cc

index 7058a9e2feabb447f5ed8f675357450908419ee5..00ffcb7ac3c05ed30af59a88d3078f537e67c792 100644 (file)
@@ -110,7 +110,12 @@ void ICAPClientReqmodPrecache::noteSinkAbort(MsgPipe *p)
 void ICAPClientReqmodPrecache::noteSourceStart(MsgPipe *p)
 {
     debug(93,3)("ICAPClientReqmodPrecache::noteSourceStart() called\n");
-    assert(adapted->data->header);     // What should happen instead?
+    /*
+     * If adapted->data->header is NULL then the ICAP response did
+     * not have a req/res-hdr section.  Send the NULL pointer to
+     * tell the other side to use the original request/response
+     * headers.
+     */
     http->takeAdaptedHeaders(adapted->data->header);
     noteSourceProgress(p);
 }
index bd99d9f54d13d249ad67d3124ff80826a7cba607..cc184f5d36bfa54d5ded7235c0181b7e24380dd0 100644 (file)
@@ -690,7 +690,7 @@ void ICAPModXact::parseHttpHead()
         maybeAllocateHttpMsg();
 
         if (!parseHead(adapted->data->header))
-            return;
+            return;    // need more header data
     }
 
     state.parsing = State::psBody;
@@ -724,7 +724,7 @@ void ICAPModXact::parseBody()
 
     debugs(93, 5, HERE << "have " << readBuf.contentSize() << " body bytes to parse");
 
-    if (gotEncapsulated("res-body")) {
+    if (gotEncapsulated("res-body") || gotEncapsulated("req-body")) {
         if (!parsePresentBody()) // need more body data
             return;
     } else {
index 2b00457b84033a9bcdade0c77954b211e5d9166d..db5608f8c14d91cbd7ed81e25ad2583f2bac079c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.54 2005/12/06 00:01:23 wessels Exp $
+ * $Id: client_side_request.cc,v 1.55 2005/12/20 23:22:29 wessels Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -1120,23 +1120,32 @@ ClientHttpRequest::takeAdaptedHeaders(HttpMsg *msg)
     assert(cbdataReferenceValid(this));                // indicates bug
 
     HttpRequest *new_req = dynamic_cast<HttpRequest*>(msg);
-    assert(new_req);
-    /*
-     * Replace the old request with the new request.  First,
-     * Move the "body_connection" over, then unlink old and
-     * link new to the http state.
-     */
-    new_req->body_connection = request->body_connection;
-    request->body_connection = NULL;
-    requestUnlink(request);
-    request = requestLink(new_req);
+
     /*
-     * Store the new URI for logging
+     * new_req will be NULL if the ICAP response doesn't have new
+     * request headers for us.  Unfortunately, it will also be NULL
+     * if someone passes us an HttpReply as an HttpMsg, which would
+     * be a bug.
      */
-    xfree(uri);
-    uri = xstrdup(urlCanonical(request));
-    setLogUri(this, urlCanonicalClean(request));
-    assert(request->method);
+
+    if (new_req) {
+        /*
+         * Replace the old request with the new request.  First,
+         * Move the "body_connection" over, then unlink old and
+         * link new to the http state.
+         */
+        new_req->body_connection = request->body_connection;
+        request->body_connection = NULL;
+        requestUnlink(request);
+        request = requestLink(new_req);
+        /*
+         * Store the new URI for logging
+         */
+        xfree(uri);
+        uri = xstrdup(urlCanonical(request));
+        setLogUri(this, urlCanonicalClean(request));
+        assert(request->method);
+    }
 
     doCallouts();