http_request.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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:取Cookie
  46. ***************************************************************************/
  47. bool cookie(const std::string& name, std::string& value);
  48. /***************************************************************************
  49. * function:取Session
  50. ***************************************************************************/
  51. network::http::session* session(const std::string& name);
  52. /***************************************************************************
  53. * function:取reqpack
  54. ***************************************************************************/
  55. network::http::reqpack* reqpack();
  56. /***************************************************************************
  57. * function:解析器
  58. ***************************************************************************/
  59. network::http::parser* parser();
  60. /***************************************************************************
  61. * function:Get Browserr Remote Ipaddress
  62. ***************************************************************************/
  63. std::string remote_ipaddress(bool find_header = false, const std::string& inside_ipaddress = "");
  64. ushort remote_port();
  65. friend class reqpack;
  66. private:
  67. network::http::reqpack* m_reqpack;
  68. network::http::session* m_session;
  69. network::http::parser m_parser;
  70. };
  71. }
  72. }
  73. }
  74. #endif