QNetworkCookieJar

Synopsis

Functions

Virtual functions

Detailed Description

The PySide.QtNetwork.QNetworkCookieJar class implements a simple jar of PySide.QtNetwork.QNetworkCookie objects

Cookies are small bits of information that stateless protocols like HTTP use to maintain some persistent information across requests.

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.

The cookie jar is the object that holds all cookies set in previous requests. Web browsers save their cookie jars to disk in order to conserve permanent cookies across invocations of the application.

PySide.QtNetwork.QNetworkCookieJar does not implement permanent storage: it only keeps the cookies in memory. Once the PySide.QtNetwork.QNetworkCookieJar object is deleted, all cookies it held will be discarded as well. If you want to save the cookies, you should derive from this class and implement the saving to disk to your own storage format.

This class implements only the basic security recommended by the cookie specifications and does not implement any cookie acceptance policy (it accepts all cookies set by any requests). In order to override those rules, you should reimplement the PySide.QtNetwork.QNetworkCookieJar.cookiesForUrl() and PySide.QtNetwork.QNetworkCookieJar.setCookiesFromUrl() virtual functions. They are called by PySide.QtNetwork.QNetworkReply and PySide.QtNetwork.QNetworkAccessManager when they detect new cookies and when they require cookies.

class PySide.QtNetwork.QNetworkCookieJar([parent=None])
Parameters:parentPySide.QtCore.QObject

Creates a PySide.QtNetwork.QNetworkCookieJar object and sets the parent object to be parent .

The cookie jar is initialized to empty.

PySide.QtNetwork.QNetworkCookieJar.allCookies()
Return type:

Returns all cookies stored in this cookie jar. This function is suitable for derived classes to save cookies to disk, as well as to implement cookie expiration and other policies.

PySide.QtNetwork.QNetworkCookieJar.cookiesForUrl(url)
Parameters:urlPySide.QtCore.QUrl
Return type:

Returns the cookies to be added to when a request is sent to url . This function is called by the default QNetworkAccessManager.createRequest() , which adds the cookies returned by this function to the request being sent.

If more than one cookie with the same name is found, but with differing paths, the one with longer path is returned before the one with shorter path. In other words, this function returns cookies sorted decreasingly by path length.

The default PySide.QtNetwork.QNetworkCookieJar class implements only a very basic security policy (it makes sure that the cookies’ domain and path match the reply’s). To enhance the security policy with your own algorithms, override PySide.QtNetwork.QNetworkCookieJar.cookiesForUrl() .

PySide.QtNetwork.QNetworkCookieJar.setAllCookies(cookieList)
Parameters:cookieList
PySide.QtNetwork.QNetworkCookieJar.setCookiesFromUrl(cookieList, url)
Parameters:
Return type:

PySide.QtCore.bool