]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/Action.cc
2 * DEBUG: section 16 Cache Manager API
7 #include "comm/Connection.h"
10 #include "mgr/Action.h"
11 #include "mgr/ActionCreator.h"
12 #include "mgr/ActionParams.h"
13 #include "mgr/ActionProfile.h"
14 #include "mgr/Command.h"
15 #include "mgr/Request.h"
16 #include "mgr/Response.h"
17 #include "SquidTime.h"
20 Mgr::Action::Action(const Command::Pointer
&aCmd
): cmd(aCmd
)
23 Must(cmd
->profile
!= NULL
);
26 Mgr::Action::~Action()
31 Mgr::Action::command() const
38 Mgr::Action::atomic() const
40 return command().profile
->isAtomic
;
44 Mgr::Action::name() const
46 return command().profile
->name
;
50 Mgr::Action::createStoreEntry() const
52 const ActionParams
¶ms
= command().params
;
53 const char *uri
= params
.httpUri
.termedBuf();
54 return storeCreateEntry(uri
, uri
, params
.httpFlags
, params
.httpMethod
);
58 Mgr::Action::add(const Action
& action
)
63 Mgr::Action::respond(const Request
& request
)
67 // Assume most kid classes are fully aggregatable (i.e., they do not dump
68 // local info at all). Do not import the remote HTTP fd into our Comm
69 // space; collect and send an IPC msg with collected info to Coordinator.
70 ::close(request
.conn
->fd
);
71 request
.conn
->fd
= -1;
73 sendResponse(request
.requestId
);
77 Mgr::Action::sendResponse(unsigned int requestId
)
79 Response
response(requestId
, this);
80 Ipc::TypedMsgHdr message
;
81 response
.pack(message
);
82 Ipc::SendMessage(Ipc::Port::CoordinatorAddr(), message
);
86 Mgr::Action::run(StoreEntry
* entry
, bool writeHttpHeader
)
90 fillEntry(entry
, writeHttpHeader
);
94 Mgr::Action::fillEntry(StoreEntry
* entry
, bool writeHttpHeader
)
99 if (writeHttpHeader
) {
100 HttpReply
*rep
= new HttpReply
;
101 rep
->setHeaders(Http::scOkay
, NULL
, contentType(), -1, squid_curtime
, squid_curtime
);
102 // Allow cachemgr and other XHR scripts access to our version string
103 const ActionParams
¶ms
= command().params
;
104 if (params
.httpOrigin
.size() > 0) {
105 rep
->header
.putExt("Access-Control-Allow-Origin", params
.httpOrigin
.termedBuf());
106 #if HAVE_AUTH_MODULE_BASIC
107 rep
->header
.putExt("Access-Control-Allow-Credentials","true");
109 rep
->header
.putExt("Access-Control-Expose-Headers","Server");
111 entry
->replaceHttpReply(rep
);