]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/Action.cc
4 * DEBUG: section 16 Cache Manager API
9 #include "comm/Connection.h"
10 #include "HttpReply.h"
12 #include "mgr/ActionCreator.h"
13 #include "mgr/Action.h"
14 #include "mgr/ActionParams.h"
15 #include "mgr/ActionProfile.h"
16 #include "mgr/Command.h"
17 #include "mgr/Request.h"
18 #include "mgr/Response.h"
19 #include "SquidTime.h"
22 Mgr::Action::Action(const Command::Pointer
&aCmd
): cmd(aCmd
)
25 Must(cmd
->profile
!= NULL
);
28 Mgr::Action::~Action()
33 Mgr::Action::command() const
40 Mgr::Action::atomic() const
42 return command().profile
->isAtomic
;
46 Mgr::Action::name() const
48 return command().profile
->name
;
52 Mgr::Action::createStoreEntry() const
54 const ActionParams
¶ms
= command().params
;
55 const char *uri
= params
.httpUri
.termedBuf();
56 return storeCreateEntry(uri
, uri
, params
.httpFlags
, params
.httpMethod
);
60 Mgr::Action::add(const Action
& action
)
65 Mgr::Action::respond(const Request
& request
)
69 // Assume most kid classes are fully aggregatable (i.e., they do not dump
70 // local info at all). Do not import the remote HTTP fd into our Comm
71 // space; collect and send an IPC msg with collected info to Coordinator.
72 ::close(request
.conn
->fd
);
73 request
.conn
->fd
= -1;
75 sendResponse(request
.requestId
);
79 Mgr::Action::sendResponse(unsigned int requestId
)
81 Response
response(requestId
, this);
82 Ipc::TypedMsgHdr message
;
83 response
.pack(message
);
84 Ipc::SendMessage(Ipc::coordinatorAddr
, message
);
88 Mgr::Action::run(StoreEntry
* entry
, bool writeHttpHeader
)
92 fillEntry(entry
, writeHttpHeader
);
96 Mgr::Action::fillEntry(StoreEntry
* entry
, bool writeHttpHeader
)
101 if (writeHttpHeader
) {
102 HttpReply
*rep
= new HttpReply
;
103 rep
->setHeaders(HTTP_OK
, NULL
, "text/plain", -1, squid_curtime
, squid_curtime
);
104 // Allow cachemgr and other XHR scripts access to our version string
105 const ActionParams
¶ms
= command().params
;
106 if (params
.httpOrigin
.size() > 0) {
107 rep
->header
.putExt("Access-Control-Allow-Origin", params
.httpOrigin
.termedBuf());
108 #if HAVE_AUTH_MODULE_BASIC
109 rep
->header
.putExt("Access-Control-Allow-Credentials","true");
111 rep
->header
.putExt("Access-Control-Expose-Headers","Server");
113 entry
->replaceHttpReply(rep
);