http_header.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include "define.h"
  3. #if USE_NET_HTTP_UTIL
  4. #include <map>
  5. namespace ylib
  6. {
  7. namespace network
  8. {
  9. namespace http
  10. {
  11. class header
  12. {
  13. public:
  14. header();
  15. ~header();
  16. void clear();
  17. void name(const std::string& value);
  18. std::string name() const;
  19. std::map<std::string, std::string> param();
  20. void parse(const std::string& body);
  21. void push(const std::string& value);
  22. void push(const std::string& key, const std::string& value);
  23. bool exist(const std::string& key);
  24. std::string to_string() const;
  25. private:
  26. std::string m_name;
  27. std::map<std::string, std::string> m_param;
  28. std::vector<std::string> m_values;
  29. };
  30. class header_list
  31. {
  32. public:
  33. header_list();
  34. ~header_list();
  35. bool exist(const std::string& name) const;
  36. ylib::network::http::header get(const std::string& name);
  37. void set(const std::string& name, const ylib::network::http::header& header);
  38. void set(const std::string& name, const std::string& value);
  39. void del(const std::string& name);
  40. std::map<std::string, std::string> to() const;
  41. size_t size();
  42. void clear();
  43. private:
  44. std::map<std::string, header> m_headers;
  45. };
  46. }
  47. }
  48. }
  49. #endif