HttpHandler.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef HTTP_HANDLER_H_
  2. #define HTTP_HANDLER_H_
  3. #include "HttpService.h"
  4. #include "HttpParser.h"
  5. #include "FileCache.h"
  6. class HttpHandler {
  7. public:
  8. enum ProtoType {
  9. UNKNOWN,
  10. HTTP_V1,
  11. HTTP_V2,
  12. WEBSOCKET,
  13. } proto;
  14. // peeraddr
  15. char ip[64];
  16. int port;
  17. // for handle_request
  18. HttpService* service;
  19. FileCache* files;
  20. file_cache_t* fc;
  21. HttpRequest req;
  22. HttpResponse res;
  23. HttpParserPtr parser;
  24. HttpHandler() {
  25. proto = UNKNOWN;
  26. service = NULL;
  27. files = NULL;
  28. fc = NULL;
  29. }
  30. ~HttpHandler() {
  31. }
  32. // @workflow: preprocessor -> api -> web -> postprocessor
  33. // @result: HttpRequest -> HttpResponse/file_cache_t
  34. int HandleHttpRequest();
  35. // TODO
  36. // int HandleWebsocketMessage(void* buf, int len);
  37. void Reset() {
  38. req.Reset();
  39. res.Reset();
  40. fc = NULL;
  41. }
  42. };
  43. #endif // HTTP_HANDLER_H_