]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Try to return a template error page. Also return 404 error code
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 28 Jan 2011 18:35:12 +0000 (20:35 +0200)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 28 Jan 2011 18:35:12 +0000 (20:35 +0200)
src/mgr/Inquirer.cc

index 1c8b5bbc1fc10bbe94dc0f2cb1e9797ffe329198..8b9c54b8aaf9bee206db2fcae9cdc6c5eca23d68 100644 (file)
@@ -10,6 +10,7 @@
 #include "comm/Write.h"
 #include "CommCalls.h"
 #include "HttpReply.h"
+#include "HttpRequest.h"
 #include "ipc/Coordinator.h"
 #include "mgr/ActionWriter.h"
 #include "mgr/Command.h"
@@ -18,6 +19,7 @@
 #include "mgr/Request.h"
 #include "mgr/Response.h"
 #include "SquidTime.h"
+#include "errorpage.h"
 #include <memory>
 #include <algorithm>
 
@@ -82,11 +84,23 @@ Mgr::Inquirer::start()
     debugs(16, 5, HERE);
     Must(fd >= 0);
     Must(aggrAction != NULL);
-
-    std::auto_ptr<HttpReply> reply(new HttpReply);
-    reply->setHeaders(strands.empty() ? HTTP_BAD_REQUEST : HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
-    reply->header.putStr(HDR_CONNECTION, "close"); // until we chunk response
-    std::auto_ptr<MemBuf> replyBuf(reply->pack());
+    std::auto_ptr<MemBuf> replyBuf;
+    if (strands.empty()) {
+        LOCAL_ARRAY(char, url, MAX_URL);
+        snprintf(url, MAX_URL, "%s", aggrAction->command().params.httpUri.termedBuf());
+        HttpRequest *req = HttpRequest::CreateFromUrl(url);
+        ErrorState *err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND, req);
+        std::auto_ptr<HttpReply> reply(err->BuildHttpReply());
+        replyBuf.reset(reply->pack());
+        errorStateFree(err);
+    }
+    else {
+        std::auto_ptr<HttpReply> reply(new HttpReply);
+        reply->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
+        reply->header.putStr(HDR_CONNECTION, "close"); // until we chunk response
+        replyBuf.reset(reply->pack());
+    }
     writer = asyncCall(16, 5, "Mgr::Inquirer::noteWroteHeader",
                        CommCbMemFunT<Inquirer, CommIoCbParams>(this, &Inquirer::noteWroteHeader));
     Comm::Write(fd, replyBuf.get(), writer);