Menu

[r2375]: / framework / trunk / cppcms / http_cookie.h  Maximize  Restore  History

Download this file

178 lines (148 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCMS_HTTP_COOKIE_H
#define CPPCMS_HTTP_COOKIE_H
#include <cppcms/defs.h>
#include <booster/copy_ptr.h>
#include <string>
#include <iostream>
#include <cppcms/cstdint.h>
namespace cppcms { namespace http {
class cookie;
std::ostream CPPCMS_API &operator<<(std::ostream &,cookie const &);
///
/// \brief Class that represents single HTTP Cookie
/// Generally used in context of http::request and http::response
///
class CPPCMS_API cookie {
public:
///
/// Cookie's Name
///
std::string name() const;
///
/// Cookie's value
///
std::string value() const;
///
/// Cookie's path
///
std::string path() const;
///
/// Cookie's domain
///
std::string domain() const;
///
/// Cookie's comment
///
std::string comment() const;
///
/// Check if the cookie is transferred over secure connection only
///
bool secure() const;
///
/// Set cookie's name
///
void name(std::string n);
///
/// Set cookie's value
///
void value(std::string v);
///
/// Set cookie's path
///
void path(std::string p);
///
/// Set cookie's domain
///
void domain(std::string);
///
/// Set cookie's comment
///
void comment(std::string);
///
/// Set expiration date/time
///
void expires(time_t when);
///
/// Returns expires timestamp for the cookie, if not set returns 0
///
/// \ver{v1_2}
time_t expires() const;
///
/// returns true if expires(time_t when) was called and expiration was set,
/// if browser_age() is called it is reset to false
///
/// \ver{v1_2}
bool expires_defined() const;
///
/// Set max cookie's age
///
void max_age(unsigned age);
///
/// Get max cookie's age, returns 0 if not set
///
/// \ver{v1_2}
unsigned max_age() const;
///
/// returns true if max(unsigned age) was called and max_age was set,
/// if browser_age() is called it is reset to false
///
/// \ver{v1_2}
bool max_age_defined() const;
///
/// Set age according to browser's session (i.e. no Max-Age)
///
void browser_age();
///
/// Set secure property on the cookies
///
void secure(bool v);
///
/// Check if cookie is not assigned - empty
///
bool empty() const;
cookie();
~cookie();
cookie(cookie const &);
cookie const &operator=(cookie const &);
///
/// Create cookie with name and value, age - browser, rest properties undefined.
///
cookie(std::string name,std::string value);
///
/// Create cookies with name, value and max-age, rest properties undefined.
///
cookie(std::string name,std::string value,unsigned age);
///
/// Create cookie with name, value, max-age, path, domain and command
///
cookie(std::string name,std::string value,unsigned age,std::string path,std::string domain = std::string(),std::string comment=std::string());
///
/// Create cookie with name, value, path, domain and comment, age - browser.
cookie(std::string name,std::string value,std::string path,std::string domain=std::string(),std::string comment=std::string());
private:
friend std::ostream &operator<<(std::ostream &,cookie const &);
void write(std::ostream &) const;
// for future use
struct _data;
booster::copy_ptr<_data> d;
// real members
std::string name_;
std::string value_;
std::string path_;
std::string domain_;
std::string comment_;
unsigned max_age_;
uint32_t secure_ : 1;
uint32_t has_age_ : 1;
uint32_t has_expiration_: 1;
uint32_t reserved_ : 29;
};
} } //::cppcms::http
#endif
MongoDB Logo MongoDB