HttpParser.cpp 525 B

1234567891011121314151617181920212223242526
  1. #include "HttpParser.h"
  2. #include "Http1Parser.h"
  3. #include "Http2Parser.h"
  4. #include "hlog.h"
  5. HttpParser* HttpParser::New(http_session_type type, http_version version) {
  6. HttpParser* hp = NULL;
  7. if (version == HTTP_V1) {
  8. hp = new Http1Parser(type);
  9. }
  10. else if (version == HTTP_V2) {
  11. #ifdef WITH_NGHTTP2
  12. hp = new Http2Parser(type);
  13. #else
  14. hlogi("Please recompile WITH_NGHTTP2!\n");
  15. #endif
  16. }
  17. if (hp) {
  18. hp->version = version;
  19. hp->type = type;
  20. }
  21. return hp;
  22. }