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 178 179 180 181 182 183 184 185 186 187
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QNetworkCookie Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkCookie Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkCookie class holds one network cookie. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qnetworkcookie.html#RawForm-enum">RawForm</a></b> { NameAndValueOnly, Full }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkcookie.html#QNetworkCookie">__init__</a></b> (<i>self</i>, QByteArray <i>name</i> = QByteArray(), QByteArray <i>value</i> = QByteArray())</li><li><div class="fn" /><b><a href="qnetworkcookie.html#QNetworkCookie-2">__init__</a></b> (<i>self</i>, QNetworkCookie <i>other</i>)</li><li><div class="fn" />QString <b><a href="qnetworkcookie.html#domain">domain</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qnetworkcookie.html#expirationDate">expirationDate</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qnetworkcookie.html#isHttpOnly">isHttpOnly</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qnetworkcookie.html#isSecure">isSecure</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qnetworkcookie.html#isSessionCookie">isSessionCookie</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qnetworkcookie.html#name">name</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkcookie.html#path">path</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setDomain">setDomain</a></b> (<i>self</i>, QString <i>domain</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setExpirationDate">setExpirationDate</a></b> (<i>self</i>, QDateTime <i>date</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setHttpOnly">setHttpOnly</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setName">setName</a></b> (<i>self</i>, QByteArray <i>cookieName</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setPath">setPath</a></b> (<i>self</i>, QString <i>path</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setSecure">setSecure</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qnetworkcookie.html#setValue">setValue</a></b> (<i>self</i>, QByteArray <i>value</i>)</li><li><div class="fn" />QByteArray <b><a href="qnetworkcookie.html#toRawForm">toRawForm</a></b> (<i>self</i>, RawForm <i>form</i> = QNetworkCookie.Full)</li><li><div class="fn" />QByteArray <b><a href="qnetworkcookie.html#value">value</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />list-of-QNetworkCookie <b><a href="qnetworkcookie.html#parseCookies">parseCookies</a></b> (QByteArray <i>cookieString</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qnetworkcookie.html#__eq__">__eq__</a></b> (<i>self</i>, QNetworkCookie <i>other</i>)</li><li><div class="fn" />bool <b><a href="qnetworkcookie.html#__ne__">__ne__</a></b> (<i>self</i>, QNetworkCookie <i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkCookie class holds one network cookie.</p>
<p>Cookies are small bits of information that stateless protocols
like HTTP use to maintain some persistent information across
requests.</p>
<p>A cookie is set by a remote server when it replies to a request
and it expects the same cookie to be sent back when further
requests are sent.</p>
<p>QNetworkCookie holds one such cookie as received from the
network. A cookie has a name and a value, but those are opaque to
the application (that is, the information stored in them has no
meaning to the application). A cookie has an associated path name
and domain, which indicate when the cookie should be sent again to
the server.</p>
<p>A cookie can also have an expiration date, indicating its
validity. If the expiration date is not present, the cookie is
considered a "session cookie" and should be discarded when the
application exits (or when its concept of session is over).</p>
<p>QNetworkCookie provides a way of parsing a cookie from the HTTP
header format using the <a href="qnetworkcookie.html#parseCookies">QNetworkCookie.parseCookies</a>()
function. However, when received in a <a href="qnetworkreply.html">QNetworkReply</a>, the cookie is already
parsed.</p>
<p>This class implements cookies as described by the <a href="http://cgi.netscape.com/newsref/std/cookie_spec.html">initial
cookie specification by Netscape</a>, which is somewhat similar to
the <a href="http://www.rfc-editor.org/rfc/rfc2109.txt">RFC
2109</a> specification, plus the <a href="http://msdn.microsoft.com/en-us/library/ms533046(VS.85).aspx">"HttpOnly"
extension</a>. The more recent <a href="http://www.rfc-editor.org/rfc/rfc2965.txt">RFC 2965</a>
specification (which uses the Set-Cookie2 header) is not
supported.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="RawForm-enum" />QNetworkCookie.RawForm</h3><p>This enum is used with the <a href="qnetworkcookie.html#toRawForm">toRawForm</a>() function to declare
which form of a cookie shall be returned.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkCookie.NameAndValueOnly</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">makes <a href="qnetworkcookie.html#toRawForm">toRawForm</a>() return only the
"NAME=VALUE" part of the cookie, as suitable for sending back to a
server in a client request's "Cookie:" header. Multiple cookies are
separated by a semi-colon in the "Cookie:" header field.</td>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkCookie.Full</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">makes <a href="qnetworkcookie.html#toRawForm">toRawForm</a>() return the full
cookie contents, as suitable for sending to a client in a server's
"Set-Cookie:" header.</td>
</tr>
</table>
<p>Note that only the Full form of the cookie can be parsed back
into its original contents.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#toRawForm">toRawForm</a>() and <a href="qnetworkcookie.html#parseCookies">parseCookies</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkCookie" />QNetworkCookie.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>name</i> = QByteArray(), <a href="qbytearray.html">QByteArray</a> <i>value</i> = QByteArray())</h3><p>Create a new <a href="qnetworkcookie.html">QNetworkCookie</a>
object, initializing the cookie name to <i>name</i> and its value
to <i>value</i>.</p>
<p>A cookie is only valid if it has a name. However, the value is
opaque to the application and being empty may have significance to
the remote server.</p>
<h3 class="fn"><a name="QNetworkCookie-2" />QNetworkCookie.__init__ (<i>self</i>, <a href="qnetworkcookie.html">QNetworkCookie</a> <i>other</i>)</h3><p>Creates a new <a href="qnetworkcookie.html">QNetworkCookie</a>
object by copying the contents of <i>other</i>.</p>
<h3 class="fn"><a name="domain" />QString QNetworkCookie.domain (<i>self</i>)</h3><p>Returns the domain this cookie is associated with. This
corresponds to the "domain" field of the cookie string.</p>
<p>Note that the domain here may start with a dot, which is not a
valid hostname. However, it means this cookie matches all hostnames
ending with that domain name.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#setDomain">setDomain</a>().</p>
<h3 class="fn"><a name="expirationDate" /><a href="qdatetime.html">QDateTime</a> QNetworkCookie.expirationDate (<i>self</i>)</h3><p>Returns the expiration date for this cookie. If this cookie is a
session cookie, the <a href="qdatetime.html">QDateTime</a> returned
will not be valid. If the date is in the past, this cookie has
already expired and should not be sent again back to a remote
server.</p>
<p>The expiration date corresponds to the parameters of the
"expires" entry in the cookie string.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#isSessionCookie">isSessionCookie</a>() and
<a href="qnetworkcookie.html#setExpirationDate">setExpirationDate</a>().</p>
<h3 class="fn"><a name="isHttpOnly" />bool QNetworkCookie.isHttpOnly (<i>self</i>)</h3><p>Returns true if the "HttpOnly" flag is enabled for this
cookie.</p>
<p>A cookie that is "HttpOnly" is only set and retrieved by the
network requests and replies; i.e., the HTTP protocol. It is not
accessible from scripts running on browsers.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#isSecure">isSecure</a>().</p>
<h3 class="fn"><a name="isSecure" />bool QNetworkCookie.isSecure (<i>self</i>)</h3><p>Returns true if the "secure" option was specified in the cookie
string, false otherwise.</p>
<p>Secure cookies may contain private information and should not be
resent over unencrypted connections.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#setSecure">setSecure</a>().</p>
<h3 class="fn"><a name="isSessionCookie" />bool QNetworkCookie.isSessionCookie (<i>self</i>)</h3><p>Returns true if this cookie is a session cookie. A session
cookie is a cookie which has no expiration date, which means it
should be discarded when the application's concept of session is
over (usually, when the application exits).</p>
<p><b>See also</b> <a href="qnetworkcookie.html#expirationDate">expirationDate</a>() and
<a href="qnetworkcookie.html#setExpirationDate">setExpirationDate</a>().</p>
<h3 class="fn"><a name="name" /><a href="qbytearray.html">QByteArray</a> QNetworkCookie.name (<i>self</i>)</h3><p>Returns the name of this cookie. The only mandatory field of a
cookie is its name, without which it is not considered valid.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#setName">setName</a>() and <a href="qnetworkcookie.html#value">value</a>().</p>
<h3 class="fn"><a name="parseCookies" />list-of-QNetworkCookie QNetworkCookie.parseCookies (<a href="qbytearray.html">QByteArray</a> <i>cookieString</i>)</h3><p>Parses the cookie string <i>cookieString</i> as received from a
server response in the "Set-Cookie:" header. If there's a parsing
error, this function returns an empty list.</p>
<p>Since the HTTP header can set more than one cookie at the same
time, this function returns a <a href="qlist.html">QList</a><<a href="qnetworkcookie.html">QNetworkCookie</a>>, one for each cookie
that is parsed.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#toRawForm">toRawForm</a>().</p>
<h3 class="fn"><a name="path" />QString QNetworkCookie.path (<i>self</i>)</h3><h3 class="fn"><a name="setDomain" />QNetworkCookie.setDomain (<i>self</i>, QString <i>domain</i>)</h3><p>Sets the domain associated with this cookie to be
<i>domain</i>.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#domain">domain</a>().</p>
<h3 class="fn"><a name="setExpirationDate" />QNetworkCookie.setExpirationDate (<i>self</i>, <a href="qdatetime.html">QDateTime</a> <i>date</i>)</h3><p>Sets the expiration date of this cookie to <i>date</i>. Setting
an invalid expiration date to this cookie will mean it's a session
cookie.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#isSessionCookie">isSessionCookie</a>() and
<a href="qnetworkcookie.html#expirationDate">expirationDate</a>().</p>
<h3 class="fn"><a name="setHttpOnly" />QNetworkCookie.setHttpOnly (<i>self</i>, bool <i>enable</i>)</h3><p>Sets this cookie's "HttpOnly" flag to <i>enable</i>.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#isHttpOnly">isHttpOnly</a>().</p>
<h3 class="fn"><a name="setName" />QNetworkCookie.setName (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>cookieName</i>)</h3><p>Sets the name of this cookie to be <i>cookieName</i>. Note that
setting a cookie name to an empty <a href="qbytearray.html">QByteArray</a> will make this cookie invalid.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#name">name</a>()
and <a href="qnetworkcookie.html#value">value</a>().</p>
<h3 class="fn"><a name="setPath" />QNetworkCookie.setPath (<i>self</i>, QString <i>path</i>)</h3><p>Sets the path associated with this cookie to be <i>path</i>.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#pathx">path</a>().</p>
<h3 class="fn"><a name="setSecure" />QNetworkCookie.setSecure (<i>self</i>, bool <i>enable</i>)</h3><p>Sets the secure flag of this cookie to <i>enable</i>.</p>
<p>Secure cookies may contain private information and should not be
resent over unencrypted connections.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#isSecure">isSecure</a>().</p>
<h3 class="fn"><a name="setValue" />QNetworkCookie.setValue (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>value</i>)</h3><p>Sets the value of this cookie to be <i>value</i>.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#value">value</a>()
and <a href="qnetworkcookie.html#name">name</a>().</p>
<h3 class="fn"><a name="toRawForm" /><a href="qbytearray.html">QByteArray</a> QNetworkCookie.toRawForm (<i>self</i>, <a href="qnetworkcookie.html#RawForm-enum">RawForm</a> <i>form</i> = QNetworkCookie.Full)</h3><p>Returns the raw form of this <a href="qnetworkcookie.html">QNetworkCookie</a>. The <a href="qbytearray.html">QByteArray</a> returned by this function is
suitable for an HTTP header, either in a server response (the
Set-Cookie header) or the client request (the Cookie header). You
can choose from one of two formats, using <i>form</i>.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#parseCookies">parseCookies</a>().</p>
<h3 class="fn"><a name="value" /><a href="qbytearray.html">QByteArray</a> QNetworkCookie.value (<i>self</i>)</h3><p>Returns this cookies value, as specified in the cookie string.
Note that a cookie is still valid if its value is empty.</p>
<p>Cookie name-value pairs are considered opaque to the
application: that is, their values don't mean anything.</p>
<p><b>See also</b> <a href="qnetworkcookie.html#setValue">setValue</a>() and <a href="qnetworkcookie.html#name">name</a>().</p>
<h3 class="fn"><a name="__eq__" />bool QNetworkCookie.__eq__ (<i>self</i>, <a href="qnetworkcookie.html">QNetworkCookie</a> <i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QNetworkCookie.__ne__ (<i>self</i>, <a href="qnetworkcookie.html">QNetworkCookie</a> <i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|