From: rousskov <> Date: Thu, 27 Sep 2007 20:34:06 +0000 (+0000) Subject: Bug 2091 fix: Handle ftp URLs with HTTP request bodies. X-Git-Tag: SQUID_3_0_RC1~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=123ec4de861ed88be20e554fe439817d4763218e;p=thirdparty%2Fsquid.git Bug 2091 fix: Handle ftp URLs with HTTP request bodies. 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. --- diff --git a/src/Server.cc b/src/Server.cc index 84251cb3da..8817d1a1e5 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -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) diff --git a/src/Server.h b/src/Server.h index 3032771099..eef3f5d2b8 100644 --- a/src/Server.h +++ b/src/Server.h @@ -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; diff --git a/src/ftp.cc b/src/ftp.cc index 1bb9d4e048..4607c2b790 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -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; } diff --git a/src/http.cc b/src/http.cc index 509df70b93..4399965337 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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;