| 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 |
no test coverage detected