1
0

HttpParser.cpp 517 B

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