]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/mgr/Action.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / mgr / Action.cc
index 5adce852647f4c7f245760cc6063dbd199e35906..c5d13e4571536e0eb6e7deae7951b3e25cb1fc57 100644 (file)
@@ -5,7 +5,8 @@
  *
  */
 
-#include "config.h"
+#include "squid.h"
+#include "comm/Connection.h"
 #include "HttpReply.h"
 #include "ipc/Port.h"
 #include "mgr/ActionCreator.h"
@@ -69,7 +70,8 @@ Mgr::Action::respond(const Request& request)
     // Assume most kid classes are fully aggregatable (i.e., they do not dump
     // local info at all). Do not import the remote HTTP fd into our Comm
     // space; collect and send an IPC msg with collected info to Coordinator.
-    ::close(request.fd);
+    ::close(request.conn->fd);
+    request.conn->fd = -1;
     collect();
     sendResponse(request.requestId);
 }
@@ -100,6 +102,15 @@ Mgr::Action::fillEntry(StoreEntry* entry, bool writeHttpHeader)
     if (writeHttpHeader) {
         HttpReply *rep = new HttpReply;
         rep->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
+        // Allow cachemgr and other XHR scripts access to our version string
+        const ActionParams &params = command().params;
+        if (params.httpOrigin.size() > 0) {
+            rep->header.putExt("Access-Control-Allow-Origin", params.httpOrigin.termedBuf());
+#if HAVE_AUTH_MODULE_BASIC
+            rep->header.putExt("Access-Control-Allow-Credentials","true");
+#endif
+            rep->header.putExt("Access-Control-Expose-Headers","Server");
+        }
         entry->replaceHttpReply(rep);
     }