MCPcopy Create free account
hub / github.com/ByConity/ByConity / run

Method run

src/Server/HTTP/HTTPServerConnection.cpp:18–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void HTTPServerConnection::run()
19{
20 std::string server = params->getSoftwareVersion();
21 Poco::Net::HTTPServerSession session(socket(), params);
22
23 while (!stopped && session.hasMoreRequests())
24 {
25 try
26 {
27 std::unique_lock<std::mutex> lock(mutex);
28 if (!stopped)
29 {
30 HTTPServerResponse response(session);
31 HTTPServerRequest request(context, response, session);
32
33 Poco::Timestamp now;
34 response.setDate(now);
35 response.setVersion(request.getVersion());
36 response.setKeepAlive(params->getKeepAlive() && request.getKeepAlive() && session.canKeepAlive());
37 if (!server.empty())
38 response.set("Server", server);
39 try
40 {
41 std::unique_ptr<HTTPRequestHandler> handler(factory->createRequestHandler(request));
42
43 if (handler)
44 {
45 if (request.getExpectContinue() && response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK)
46 response.sendContinue();
47
48 handler->handleRequest(request, response);
49 session.setKeepAlive(params->getKeepAlive() && response.getKeepAlive() && session.canKeepAlive());
50 }
51 else
52 sendErrorResponse(session, Poco::Net::HTTPResponse::HTTP_NOT_IMPLEMENTED);
53 }
54 catch (Poco::Exception &)
55 {
56 if (!response.sent())
57 {
58 try
59 {
60 sendErrorResponse(session, Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
61 }
62 catch (...)
63 {
64 }
65 }
66 throw;
67 }
68 }
69 }
70 catch (const Poco::Net::NoMessageException &)
71 {
72 break;
73 }
74 catch (const Poco::Net::MessageException &)
75 {

Callers

nothing calls this directly

Calls 9

sendContinueMethod · 0.80
sentMethod · 0.80
getVersionMethod · 0.45
emptyMethod · 0.45
setMethod · 0.45
createRequestHandlerMethod · 0.45
getStatusMethod · 0.45
handleRequestMethod · 0.45
rethrowMethod · 0.45

Tested by

no test coverage detected