From: Christos Tsantilas Date: Wed, 13 Nov 2013 22:20:55 +0000 (-0700) Subject: Add EPRT and EPSV commands to FTP FEAT response if not already there X-Git-Tag: SQUID_3_5_0_1~117^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=896f0b9b08b52e2cbbd9bb61afc41a725830437e;p=thirdparty%2Fsquid.git Add EPRT and EPSV commands to FTP FEAT response if not already there because Squid FTP gw supports both even if the FTP origin server does not. --- diff --git a/src/client_side.cc b/src/client_side.cc index e900168bc3..627cb847e2 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -5287,6 +5287,8 @@ FtpHandleFeatReply(ClientSocketContext *context, const HttpReply *reply, StoreIO // Remove all unsupported commands from the response wrapper. int deletedCount = 0; HttpHeaderPos pos = HttpHeaderInitPos; + bool hasEPRT = false; + bool hasEPSV = false; while (const HttpHeaderEntry *e = filteredHeader.getEntry(&pos)) { if (e->id == HDR_FTP_PRE) { // assume RFC 2389 FEAT response format, quoted by Squid: @@ -5303,12 +5305,27 @@ FtpHandleFeatReply(ClientSocketContext *context, const HttpReply *reply, StoreIO if (!FtpSupportedCommand(cmd)) filteredHeader.delAt(pos, deletedCount); + + if (cmd == "EPRT") + hasEPRT = true; + else if (cmd == "EPSV") + hasEPSV = true; } } - if (deletedCount) { + int insertedCount = 0; + if (!hasEPRT) { + filteredHeader.putStr(HDR_FTP_PRE, "\" EPRT\""); + ++insertedCount; + } + if (!hasEPSV) { + filteredHeader.putStr(HDR_FTP_PRE, "\" EPSV\""); + ++insertedCount; + } + + if (deletedCount || insertedCount) { filteredHeader.refreshMask(); - debugs(33, 5, "deleted " << deletedCount); + debugs(33, 5, "deleted " << deletedCount << " inserted " << insertedCount); } FtpWriteForwardedReply(context, filteredReply);