MCPcopy Create free account
hub / github.com/chenshuo/muduo / onRequest

Function onRequest

examples/fastcgi/fastcgi_test.cc:13–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11const string kPath = "/sudoku/";
12
13void onRequest(const TcpConnectionPtr& conn,
14 FastCgiCodec::ParamMap& params,
15 Buffer* in)
16{
17 string uri = params["REQUEST_URI"];
18 LOG_INFO << conn->name() << ": " << uri;
19
20 for (FastCgiCodec::ParamMap::const_iterator it = params.begin();
21 it != params.end(); ++it)
22 {
23 LOG_DEBUG << it->first << " = " << it->second;
24 }
25 if (in->readableBytes() > 0)
26 LOG_DEBUG << "stdin " << in->retrieveAllAsString();
27 Buffer response;
28 response.append("Context-Type: text/plain\r\n\r\n");
29 if (uri.size() == kCells + kPath.size() && uri.find(kPath) == 0)
30 {
31 response.append(solveSudoku(uri.substr(kPath.size())));
32 }
33 else
34 {
35 // FIXME: set http status code 400
36 response.append("bad request");
37 }
38
39 FastCgiCodec::respond(&response);
40 conn->send(&response);
41}
42
43void onConnection(const TcpConnectionPtr& conn)
44{

Callers

nothing calls this directly

Calls 8

solveSudokuFunction · 0.85
readableBytesMethod · 0.80
retrieveAllAsStringMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected