Hobrasoft httpd server
Embedded HTTP server for Qt and C++
httpcookie.cpp
Go to the documentation of this file.
1 
8 #include "httpcookie.h"
9 
10 using namespace HobrasoftHttpd;
11 
12 
14  m_version = 1;
15  m_maxAge = 0;
16  m_secure = false;
17 }
18 
19 
21  const QString& name,
22  const QString& value,
23  const int maxAge,
24  const QString& path,
25  const QString& comment,
26  const QString& domain,
27  const bool secure) {
28  m_name = name;
29  m_value = value;
30  m_maxAge = maxAge;
31  m_path = path;
32  m_comment = comment;
33  m_domain = domain;
34  m_secure = secure;
35  m_version = 1;
36 }
37 
38 
39 QByteArray HttpCookie::toByteArray() const {
40  QString buffer;
41  buffer += m_name;
42  buffer += "=";
43  buffer += m_value;
44 
45  if (!m_comment.isEmpty()) {
46  buffer += "; Comment=";
47  buffer += m_comment;
48  }
49 
50  if (!m_domain.isEmpty()) {
51  buffer += "; Domain=";
52  buffer += m_domain;
53  }
54 
55  if (m_maxAge != 0) {
56  buffer += "; Max-Age=";
57  buffer += QString("%1").arg(m_maxAge);
58  }
59 
60  if (!m_path.isEmpty()) {
61  buffer += "; Path=";
62  buffer += m_path;
63  }
64 
65  if (m_secure) {
66  buffer += "; Secure";
67  }
68 
69  buffer += "; Version=";
70  buffer += QString("%1").arg(m_version);
71 
72  return buffer.toUtf8();
73 }
74 
QString path() const
Returns the path of cookie.
Definition: httpcookie.h:59
bool secure() const
Returns the secure status of cookie.
Definition: httpcookie.h:60
QString name() const
Returns the name of cookie.
Definition: httpcookie.h:54
QByteArray toByteArray() const
Returns cookie on form of line formated for HTTP header.
Definition: httpcookie.cpp:39
int maxAge() const
Returns the max age of cookie.
Definition: httpcookie.h:58
QString comment() const
Returns the comment of cookie.
Definition: httpcookie.h:56
QString value() const
Returns the value of cookie.
Definition: httpcookie.h:55
HttpCookie()
Constructor, creates an empty cookie.
Definition: httpcookie.cpp:13
Namespace of HTTP server.
QString domain() const
Returns the domain of cookie.
Definition: httpcookie.h:57