| 26 | } |
| 27 | |
| 28 | void CHttpServer::OnMessage(const cppnet::Handle& handle, base::CBuffer* data, |
| 29 | uint32_t, uint32_t err) { |
| 30 | |
| 31 | if (err != CEC_SUCCESS) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | _mutex.lock(); |
| 36 | CHttpContext& context = _context_map[handle]; |
| 37 | _mutex.unlock(); |
| 38 | |
| 39 | _time_tool.Now(); |
| 40 | if (!context.ParseRequest(data, _time_tool.GetMsec())) { |
| 41 | handle->Write("HTTP/1.1 400 Bad Request\r\n\r\n", sizeof("HTTP/1.1 400 Bad Request\r\n\r\n")); |
| 42 | handle->Close(); |
| 43 | } |
| 44 | |
| 45 | if (context.IsGotAll()) { |
| 46 | OnRequest(handle, context.GetRequest()); |
| 47 | context.Reset(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void CHttpServer::OnMessageSend(const cppnet::Handle& , uint32_t , uint32_t ) { |
| 52 | // do nothing. |