]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ICAP/ICAPModXact.cc
Author: Christos Tsantilas <chtsanti@users.sourceforge.net>
[thirdparty/squid.git] / src / ICAP / ICAPModXact.cc
index ff0412efdc0088e48105dcf7f78eb7bd7d19b69a..4bfdb9c41df9b6983734626a76a004d77725e9a9 100644 (file)
@@ -782,14 +782,16 @@ void ICAPModXact::prepEchoing()
     // allocate the adapted message and copy metainfo
     Must(!adapted.header);
     HttpMsg *newHead = NULL;
-    if (const HttpRequest *oldR = dynamic_cast<const HttpRequest*>(oldHead)) {
+    if (dynamic_cast<const HttpRequest*>(oldHead)) {
         HttpRequest *newR = new HttpRequest;
-        inheritVirginProperties(*newR, *oldR);
         newHead = newR;
-    } else
-    if (dynamic_cast<const HttpReply*>(oldHead))
-        newHead = new HttpReply;
+    } 
+    else if (dynamic_cast<const HttpReply*>(oldHead)) {
+       HttpReply *newRep = new HttpReply;
+       newHead = newRep;
+    }
     Must(newHead);
+    newHead->inheritProperties(oldHead);
 
     adapted.setHeader(newHead);
 
@@ -845,15 +847,18 @@ void ICAPModXact::parseHttpHead()
         if (!parseHead(adapted.header))
             return; // need more header data
 
-        if (HttpRequest *newHead = dynamic_cast<HttpRequest*>(adapted.header)) {
+        if (dynamic_cast<HttpRequest*>(adapted.header)) {
             const HttpRequest *oldR = dynamic_cast<const HttpRequest*>(virgin.header);
             Must(oldR);
             // TODO: the adapted request did not really originate from the 
             // client; give proxy admin an option to prevent copying of 
             // sensitive client information here. See the following thread:
             // http://www.squid-cache.org/mail-archive/squid-dev/200703/0040.html
-            inheritVirginProperties(*newHead, *oldR);
         }
+
+       // Maybe adapted.header==NULL if HttpReply and have Http 0.9 ....
+       if(adapted.header) 
+           adapted.header->inheritProperties(virgin.header);
     }
 
     decideOnParsingBody();
@@ -881,22 +886,6 @@ bool ICAPModXact::parseHead(HttpMsg *head)
     return true;
 }
 
-// TODO: Move this method to HttpRequest?
-void ICAPModXact::inheritVirginProperties(HttpRequest &newR, const HttpRequest &oldR) {
-
-    newR.client_addr = oldR.client_addr;
-    newR.my_addr = oldR.my_addr;
-
-    // This may be too conservative for the 204 No Content case
-    // may eventually need cloneNullAdaptationImmune() for that.
-    newR.flags = oldR.flags.cloneAdaptationImmune();
-
-    if (oldR.auth_user_request) {
-        newR.auth_user_request = oldR.auth_user_request;
-       AUTHUSERREQUESTLOCK(newR.auth_user_request, "newR in ICAPModXact");
-    }
-}
-
 void ICAPModXact::decideOnParsingBody() {
     if (gotEncapsulated("res-body") || gotEncapsulated("req-body")) {
         debugs(93, 5, HERE << "expecting a body");
@@ -1152,7 +1141,6 @@ void ICAPModXact::encapsulateHead(MemBuf &icapBuf, const char *section, MemBuf &
         HttpRequest* new_request = new HttpRequest;
         urlParse(old_request->method, old_request->canonical,new_request);
         new_request->http_ver = old_request->http_ver;
-        inheritVirginProperties(*new_request, *old_request);
         headClone = new_request;
     } 
     else if (const HttpReply *old_reply = dynamic_cast<const HttpReply*>(head)) {
@@ -1162,6 +1150,7 @@ void ICAPModXact::encapsulateHead(MemBuf &icapBuf, const char *section, MemBuf &
     }
     
     Must(headClone);
+    headClone->inheritProperties(head);
     
     HttpHeaderPos pos = HttpHeaderInitPos;
     HttpHeaderEntry* p_head_entry = NULL;