HttpHandler.h 851 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // peeraddr
  9. char ip[64];
  10. int port;
  11. // for handle_request
  12. HttpService* service;
  13. FileCache* files;
  14. file_cache_t* fc;
  15. HttpRequest req;
  16. HttpResponse res;
  17. HttpParserPtr parser;
  18. HttpHandler() {
  19. service = NULL;
  20. files = NULL;
  21. fc = NULL;
  22. }
  23. ~HttpHandler() {
  24. }
  25. // @workflow: preprocessor -> api -> web -> postprocessor
  26. // @result: HttpRequest -> HttpResponse/file_cache_t
  27. int HandleRequest();
  28. void Reset() {
  29. req.Reset();
  30. res.Reset();
  31. fc = NULL;
  32. }
  33. };
  34. #endif // HTTP_HANDLER_H_