HttpSession.cpp 525 B

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