]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Provide user with more details on forwarding/adaptation errors.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 23 Aug 2013 20:29:04 +0000 (14:29 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 23 Aug 2013 20:29:04 +0000 (14:29 -0600)
In addition to "421 Service Unavailable", print %c and %E errorpage info.
Needs more work to make FTP error messages configurable, just like they are
for HTTP.

src/client_side.cc

index 5ac84ce4d2e7a6e028f8177c94d7afc63b0477d6..df85e612f7768669bb6713c085ee13f2c41340aa 100644 (file)
@@ -5286,10 +5286,32 @@ FtpWriteForwardedReply(ClientSocketContext *context, const HttpReply *reply, Asy
     const HttpHeader &header = reply->header;
     ConnStateData *const connState = context->getConn();
 
+    // adaptation and forwarding errors lack HDR_FTP_STATUS
     if (!header.has(HDR_FTP_STATUS)) {
-        // Reply without FTP-Status header may come from ICAP or ACL.
         connState->ftp.state = ConnStateData::FTP_ERROR;
-        FtpWriteCustomReply(context, 421, reply->sline.reason());
+
+        assert(context->http);
+        const HttpRequest *request = context->http->request;
+        assert(request);
+
+        const int status = 421;
+        const char *reason = reply->sline.reason();
+        MemBuf mb;
+        mb.init();
+        mb.Printf("%i-%s\r\n", status, errorPageName(request->errType));
+        if (request->errDetail > 0) {
+            // XXX: > 0 may not always mean that this is an errno
+            mb.Printf("%i-Error: (%d) %s\r\n", status,
+                      request->errDetail,
+                      strerror(request->errDetail));
+        }
+        mb.Printf("%i %s\r\n", status, reason); // error terminating line
+
+        // TODO: errorpage.cc should detect FTP client and use
+        // configurable FTP-friendly error templates which we should
+        // write to the client "as is" instead of hiding most of the info
+
+        FtpWriteReply(context, mb);
         return;
     }