| 42 | } |
| 43 | |
| 44 | void onMessage(const TcpConnectionPtr& conn, Buffer* buf, Timestamp) |
| 45 | { |
| 46 | LOG_DEBUG << conn->name(); |
| 47 | size_t len = buf->readableBytes(); |
| 48 | while (len >= kCells + 2) |
| 49 | { |
| 50 | const char* crlf = buf->findCRLF(); |
| 51 | if (crlf) |
| 52 | { |
| 53 | string request(buf->peek(), crlf); |
| 54 | buf->retrieveUntil(crlf + 2); |
| 55 | len = buf->readableBytes(); |
| 56 | if (!processRequest(conn, request)) |
| 57 | { |
| 58 | conn->send("Bad Request!\r\n"); |
| 59 | conn->shutdown(); |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | else if (len > 100) // id + ":" + kCells + "\r\n" |
| 64 | { |
| 65 | conn->send("Id too long!\r\n"); |
| 66 | conn->shutdown(); |
| 67 | break; |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | break; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | bool processRequest(const TcpConnectionPtr& conn, const string& request) |
| 77 | { |
nothing calls this directly
no test coverage detected