source: XMLIO_V2/external/include/Poco/Net/HTTPCookie.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 6.1 KB
Line 
1//
2// HTTPCookie.h
3//
4// $Id: //poco/1.3/Net/include/Poco/Net/HTTPCookie.h#2 $
5//
6// Library: Net
7// Package: HTTP
8// Module:  HTTPCookie
9//
10// Definition of the HTTPCookie class.
11//
12// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Net_HTTPCookie_INCLUDED
40#define Net_HTTPCookie_INCLUDED
41
42
43#include "Poco/Net/Net.h"
44
45
46namespace Poco {
47namespace Net {
48
49
50class NameValueCollection;
51
52
53class Net_API HTTPCookie
54        /// This class represents a HTTP Cookie.
55        ///
56        /// A cookie is a small amount of information sent by a Web
57        /// server to a Web browser, saved by the browser, and later sent back
58        /// to the server. A cookie's value can uniquely identify a client, so
59        /// cookies are commonly used for session management.
60        ///
61        /// A cookie has a name, a single value, and optional attributes such
62        /// as a comment, path and domain qualifiers, a maximum age, and a
63        /// version number.
64        ///
65        /// This class supports both the Version 0 (by Netscape) and Version 1
66        /// (by RFC 2109) cookie specifications. By default, cookies are created
67        /// using Version 0 to ensure the best interoperability.
68{
69public:
70        HTTPCookie();
71                /// Creates an empty HTTPCookie.
72               
73        explicit HTTPCookie(const std::string& name);
74                /// Creates a cookie with the given name.       
75                /// The cookie never expires.
76               
77        explicit HTTPCookie(const NameValueCollection& nvc);
78                /// Creates a cookie from the given NameValueCollection.
79               
80        HTTPCookie(const std::string& name, const std::string& value);
81                /// Creates a cookie with the given name and value.
82                /// The cookie never expires.
83               
84        HTTPCookie(const HTTPCookie& cookie);
85                /// Creates the HTTPCookie by copying another one.
86
87        ~HTTPCookie();
88                /// Destroys the HTTPCookie.
89               
90        HTTPCookie& operator = (const HTTPCookie& cookie);
91                /// Assigns a cookie.
92               
93        void setVersion(int version);
94                /// Sets the version of the cookie.
95                ///
96                /// Version must be either 0 (denoting a Netscape cookie)
97                /// or 1 (denoting a RFC 2109 cookie).
98               
99        int getVersion() const;
100                /// Returns the version of the cookie, which is
101                /// either 0 or 1.     
102               
103        void setName(const std::string& name);
104                /// Sets the name of the cookie.
105               
106        const std::string& getName() const;
107                /// Returns the name of the cookie.
108               
109        void setValue(const std::string& value);
110                /// Sets the value of the cookie.
111                ///
112                /// According to the cookie specification, the
113                /// size of the value should not exceed 4 Kbytes.
114               
115        const std::string& getValue() const;
116                /// Returns the value of the cookie.
117               
118        void setComment(const std::string& comment);
119                /// Sets the comment for the cookie.
120                ///
121                /// Comments are only supported for version 1 cookies.
122
123        const std::string& getComment() const;
124                /// Returns the comment for the cookie.
125
126        void setDomain(const std::string& domain);
127                /// Sets the domain for the cookie.
128               
129        const std::string& getDomain() const;
130                /// Returns the domain for the cookie.
131
132        void setPath(const std::string& path);
133                /// Sets the path for the cookie.
134               
135        const std::string& getPath() const;
136                /// Returns the path for the cookie.
137
138        void setSecure(bool secure);
139                /// Sets the value of the secure flag for
140                /// the cookie.
141               
142        bool getSecure() const;
143                /// Returns the value of the secure flag
144                /// for the cookie.
145
146        void setMaxAge(int maxAge);
147                /// Sets the maximum age in seconds for
148                /// the cookie.
149                ///
150                /// A value of -1 causes the cookie to
151                /// never expire on the client.
152                ///
153                /// A value of 0 deletes the cookie on
154                /// the client.
155
156        int getMaxAge() const;
157                /// Returns the maximum age in seconds for
158                /// the cookie.
159               
160        void setHttpOnly(bool flag = true);
161                /// Sets the HttpOnly flag for the cookie.
162               
163        bool getHttpOnly() const;
164                /// Returns true iff the cookie's HttpOnly flag is set.
165               
166        std::string toString() const;
167                /// Returns a string representation of the cookie,
168                /// suitable for use in a Set-Cookie header.
169
170private:
171        int         _version;
172        std::string _name;
173        std::string _value;
174        std::string _comment;
175        std::string _domain;
176        std::string _path;
177        bool        _secure;
178        int         _maxAge;
179        bool        _httpOnly;
180};
181
182
183//
184// inlines
185//
186inline int HTTPCookie::getVersion() const
187{
188        return _version;
189}
190
191
192inline const std::string& HTTPCookie::getName() const
193{
194        return _name;
195}
196
197
198inline const std::string& HTTPCookie::getValue() const
199{
200        return _value;
201}
202
203
204inline const std::string& HTTPCookie::getComment() const
205{
206        return _comment;
207}
208
209
210inline const std::string& HTTPCookie::getDomain() const
211{
212        return _domain;
213}
214
215
216inline const std::string& HTTPCookie::getPath() const
217{
218        return _path;
219}
220
221
222inline bool HTTPCookie::getSecure() const
223{
224        return _secure;
225}
226
227
228inline int HTTPCookie::getMaxAge() const
229{
230        return _maxAge;
231}
232
233
234inline bool HTTPCookie::getHttpOnly() const
235{
236        return _httpOnly;
237}
238
239
240} } // namespace Poco::Net
241
242
243#endif // Net_HTTPCookie_INCLUDED
Note: See TracBrowser for help on using the repository browser.