MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / sendResponse

Function sendResponse

3ds/source/server.cpp:147–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 }
146
147 static void sendResponse(s32 clientSocket, const Server::HttpResponse& response)
148 {
149 std::string header = "HTTP/1.1 " + std::to_string(response.statusCode);
150 header += (response.statusCode == 200 ? " OK" : (response.statusCode == 404 ? " Not Found" : " Error"));
151 header += "\r\nContent-Type: " + response.contentType;
152 header += "\r\nContent-Length: " + std::to_string(response.body.length());
153 header += "\r\n\r\n";
154 send(clientSocket, header.c_str(), header.length(), 0);
155 send(clientSocket, response.body.c_str(), response.body.length(), 0);
156 }
157
158 // Streams the body of an upload request to `tmpPath`, tracking progress and
159 // honouring a receive cancel. `leftover` is the body already read while

Callers 1

handleHttpRequestFunction · 0.70

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected