MCPcopy Create free account
hub / github.com/acl-dev/acl / doService

Method doService

app/wizard/tmpl/http/http_service.cpp:118–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118bool http_service::doService(int type, HttpRequest& req, HttpResponse& res)
119{
120 if (type < http_handler_get || type >= http_handler_max) {
121 logger_error("invalid type=%d", type);
122 return false;
123 }
124
125 res.setKeepAlive(req.isKeepAlive());
126 bool keep = req.isKeepAlive();
127
128 const char* path = req.getPathInfo();
129 if (path == NULL || *path == 0) {
130 res.setStatus(400);
131 acl::string buf("400 bad request\r\n");
132 res.setContentLength(buf.size());
133 return res.write(buf.c_str(), buf.size()) && keep;
134 }
135
136 size_t len = strlen(path);
137 acl::string buf(path);
138 if (path[len - 1] != '/') {
139 buf += '/';
140 }
141 buf.lower();
142
143 std::map<acl::string, http_handler_t>::iterator it
144 = handlers_[type].find(buf);
145
146 if (it != handlers_[type].end()) {
147 return it->second(req, res) && keep;
148 }
149
150 return handler_default_(buf, req, res) && keep;
151}

Callers

nothing calls this directly

Calls 7

isKeepAliveMethod · 0.80
getPathInfoMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected