HttpCookie.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef HTTP_COOKIE_H
  22. #define HTTP_COOKIE_H
  23. /// @cond DO_NOT_SHOW
  24. #include<string>
  25. #include<vector>
  26. struct CookiesInfo
  27. {
  28. std::string domain;
  29. bool tailmatch;
  30. std::string path;
  31. bool secure;
  32. std::string name;
  33. std::string value;
  34. std::string expires;
  35. };
  36. class HttpCookie
  37. {
  38. public:
  39. void readFile();
  40. void writeFile();
  41. void setCookieFileName(const std::string& fileName);
  42. const std::vector<CookiesInfo>* getCookies()const;
  43. const CookiesInfo* getMatchCookie(const std::string& url) const;
  44. void updateOrAddCookie(CookiesInfo* cookie);
  45. private:
  46. std::string _cookieFileName;
  47. std::vector<CookiesInfo> _cookies;
  48. };
  49. /// @endcond
  50. #endif /* HTTP_COOKIE_H */