ZenLib
|
00001 /* Copyright (c) MediaArea.net SARL. All Rights Reserved. 00002 * 00003 * Use of this source code is governed by a zlib-style license that can 00004 * be found in the License.txt file in the root of the source tree. 00005 */ 00006 00007 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00008 // 00009 // Cookies handling 00010 // 00011 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00012 00013 //--------------------------------------------------------------------------- 00014 #ifndef ZenLib_Format_Http_CookiesH 00015 #define ZenLib_Format_Http_CookiesH 00016 //--------------------------------------------------------------------------- 00017 00018 //--------------------------------------------------------------------------- 00019 #include <string> 00020 #include <ctime> 00021 #include <map> 00022 #include <sstream> 00023 //--------------------------------------------------------------------------- 00024 00025 namespace ZenLib 00026 { 00027 00028 namespace Format 00029 { 00030 00031 namespace Http 00032 { 00033 00034 //*************************************************************************** 00035 /// @brief 00036 //*************************************************************************** 00037 00038 struct Cookie 00039 { 00040 std::string Value; 00041 std::time_t Expires; 00042 std::string Path; 00043 std::string Domain; 00044 bool Secure; 00045 00046 Cookie() 00047 { 00048 Expires=0; 00049 Secure=false; 00050 } 00051 }; 00052 00053 extern std::string EmptyString; //Must not change 00054 00055 class Cookies : public std::map<std::string, Cookie> 00056 { 00057 public : 00058 //Constructor/Destructor 00059 Cookies(); 00060 00061 //Helpers 00062 size_t Set(const std::string &Name, const std::string &Value=EmptyString, std::time_t Expires=(std::time_t)-1, const std::string &Path=EmptyString, const std::string &Domain=EmptyString, bool Secure=false); 00063 Cookie &Get(const std::string &Name); 00064 void Create_Lines(std::ostream& Out); 00065 }; 00066 00067 } //Namespace 00068 00069 } //Namespace 00070 00071 } //Namespace 00072 00073 #endif