http_request.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include "http_define.h"
  3. #if USE_NET_HTTP_WEBSITE
  4. #include <string>
  5. #include <vector>
  6. #include "http_session.h"
  7. #include "http_parser.h"
  8. #include "http_interface.h"
  9. namespace ylib
  10. {
  11. namespace network
  12. {
  13. namespace http
  14. {
  15. class reqpack;
  16. class server;
  17. /********************************************************************
  18. * class:Http请求解析类
  19. ********************************************************************/
  20. class request :public network::http::interface_
  21. {
  22. public:
  23. request();
  24. ~request();
  25. /***************************************************************************
  26. * function:取协议头
  27. * param
  28. * name : 名称
  29. * value : 内容
  30. ***************************************************************************/
  31. bool header(const std::string& name, std::string& value);
  32. /***************************************************************************
  33. * function:取请求类型
  34. ***************************************************************************/
  35. network::http::method method();
  36. /***************************************************************************
  37. * function:取请求路径
  38. ***************************************************************************/
  39. std::string filepath();
  40. /***************************************************************************
  41. * function:取请求主机
  42. ***************************************************************************/
  43. std::string host();
  44. /***************************************************************************
  45. * function:取Session
  46. ***************************************************************************/
  47. network::http::session& session(const std::string& session_id);
  48. /// <summary>
  49. /// 取TOKEN
  50. /// </summary>
  51. /// <returns></returns>
  52. std::string token();
  53. /***************************************************************************
  54. * function:取reqpack
  55. ***************************************************************************/
  56. network::http::reqpack* reqpack();
  57. /***************************************************************************
  58. * function:解析器
  59. ***************************************************************************/
  60. network::http::parser* parser();
  61. /***************************************************************************
  62. * function:Get Browserr Remote Ipaddress
  63. ***************************************************************************/
  64. std::string remote_ipaddress(bool find_header = false, const std::string& inside_ipaddress = "");
  65. ushort remote_port();
  66. friend class reqpack;
  67. private:
  68. network::http::reqpack* m_reqpack;
  69. network::http::session m_session;
  70. network::http::parser m_parser;
  71. };
  72. }
  73. }
  74. }
  75. #endif