]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2091 fix: Handle ftp URLs with HTTP request bodies.
authorrousskov <>
Thu, 27 Sep 2007 20:34:06 +0000 (20:34 +0000)
committerrousskov <>
Thu, 27 Sep 2007 20:34:06 +0000 (20:34 +0000)
Moved registration to receive request body from http and ftp into Server.
Ftp code was not setting the request body source member before this merge.

src/Server.cc
src/Server.h
src/ftp.cc
src/http.cc

index 84251cb3da093710f5a7df2826ea7264fd39d24e..8817d1a1e5d356446db6d17f8d0b492c2eea8b3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: Server.cc,v 1.22 2007/08/13 17:20:51 hno Exp $
+ * $Id: Server.cc,v 1.23 2007/09/27 14:34:06 rousskov Exp $
  *
  * DEBUG:
  * AUTHOR: Duane Wessels
@@ -189,6 +189,24 @@ ServerStateData::completeForwarding() {
     fwd->complete();
 }
 
+// Register to receive request body
+bool ServerStateData::startRequestBodyFlow()
+{
+    HttpRequest *r = originalRequest();
+    assert(r->body_pipe != NULL);
+    requestBodySource = r->body_pipe;
+    if (requestBodySource->setConsumerIfNotLate(this)) {
+        debugs(11,3, HERE << "expecting request body from " <<
+            requestBodySource->status());
+        return true;
+    }
+
+    debugs(11,3, HERE << "aborting on partially consumed request body: " <<
+        requestBodySource->status());
+    requestBodySource = NULL;
+    return false;
+}
+
 // Entry-dependent callbacks use this check to quit if the entry went bad
 bool
 ServerStateData::abortOnBadEntry(const char *abortReason)
index 3032771099508e4db237fcf7c1d7e7451a4eeb6e..eef3f5d2b8acf98cf7a912afeccad6e263727beb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: Server.h,v 1.9 2007/08/09 23:30:52 rousskov Exp $
+ * $Id: Server.h,v 1.10 2007/09/27 14:34:06 rousskov Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -115,6 +115,7 @@ protected:
     virtual void completeForwarding(); // default calls fwd->complete()
 
     // BodyConsumer for HTTP: consume request body.
+    bool startRequestBodyFlow();
     void handleMoreRequestBodyAvailable();
     void handleRequestBodyProductionEnded();
     virtual void handleRequestBodyProducerAborted() = 0;
index 1bb9d4e048f9e114a90523f52fffd64087372ac2..4607c2b7909e838460a1e8ebbe8c63839c82a7dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ftp.cc,v 1.440 2007/08/15 06:56:19 amosjeffries Exp $
+ * $Id: ftp.cc,v 1.441 2007/09/27 14:34:06 rousskov Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -2668,10 +2668,7 @@ void FtpStateData::readStor() {
     debugs(9, 3, "This is ftpReadStor");
 
     if (code == 125 || (code == 150 && data.host)) {
-        // register to receive body data
-        assert(request->body_pipe != NULL);
-        if (!request->body_pipe->setConsumerIfNotLate(this)) {
-            debugs(9, 3, "ftpReadStor: aborting on partially consumed body");
+        if (!startRequestBodyFlow()) { // register to receive body data
             ftpFail(this);
             return;
         }
index 509df70b93765222cdb5afcc258e43d04df034b5..4399965337277d3be917a7001752574255b1533b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.537 2007/08/13 17:20:51 hno Exp $
+ * $Id: http.cc,v 1.538 2007/09/27 14:34:06 rousskov Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1703,16 +1703,9 @@ HttpStateData::sendRequest()
     maybeReadVirginBody();
 
     if (orig_request->body_pipe != NULL) {
-        requestBodySource = orig_request->body_pipe;
-
-        if (!requestBodySource->setConsumerIfNotLate(this)) {
-            debugs(32,3, HERE << "aborting on partially consumed body");
-            requestBodySource = NULL;
+        if (!startRequestBodyFlow()) // register to receive body data
             return false;
-        }
-
         requestSender = HttpStateData::sentRequestBodyWrapper;
-        debugs(32,3, HERE << "expecting request body on pipe " << requestBodySource);
     } else {
         assert(!requestBodySource);
         requestSender = HttpStateData::SendComplete;