| 250 | } |
| 251 | |
| 252 | static bool ParseRequestLine(const char* buf, size_t len, std::string& method, std::string& path) { |
| 253 | std::string line(buf, std::min(len, (size_t)4096)); |
| 254 | auto endOfLine = line.find("\r\n"); |
| 255 | if (endOfLine != std::string::npos) line = line.substr(0, endOfLine); |
| 256 | |
| 257 | auto sp1 = line.find(' '); |
| 258 | if (sp1 == std::string::npos) return false; |
| 259 | method = line.substr(0, sp1); |
| 260 | |
| 261 | auto sp2 = line.find(' ', sp1 + 1); |
| 262 | if (sp2 == std::string::npos) return false; |
| 263 | path = line.substr(sp1 + 1, sp2 - sp1 - 1); |
| 264 | |
| 265 | return true; |
| 266 | } |
| 267 | |
| 268 | static void HandleConnection(int clientFd) { |
| 269 | char buf[8192]; |
no test coverage detected