Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QNetworkCookieJar Class Reference

The QNetworkCookieJar class implements a simple jar of QNetworkCookie objects More...

 #include <QNetworkCookieJar>

Inherits: QObject.

This class was introduced in Qt 4.4.

Public Functions

QNetworkCookieJar ( QObject * parent = 0 )
virtual ~QNetworkCookieJar ()
virtual QList<QNetworkCookie> cookiesForUrl ( const QUrl & url ) const
virtual bool setCookiesFromUrl ( const QList<QNetworkCookie> & cookieList, const QUrl & url )
  • 29 public functions inherited from QObject

Protected Functions

QList<QNetworkCookie> allCookies () const
void setAllCookies ( const QList<QNetworkCookie> & cookieList )
  • 8 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 7 static public members inherited from QObject

Detailed Description

The QNetworkCookieJar class implements a simple jar of 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.

QNetworkCookieJar does not implement permanent storage: it only keeps the cookies in memory. Once the 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 cookiesForUrl() and setCookiesFromUrl() virtual functions. They are called by QNetworkReply and QNetworkAccessManager when they detect new cookies and when they require cookies.

See also QNetworkCookie, QNetworkAccessManager, QNetworkReply, QNetworkRequest, and QNetworkAccessManager::setCookieJar().

Member Function Documentation

QNetworkCookieJar::QNetworkCookieJar ( QObject * parent = 0 )

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

The cookie jar is initialized to empty.

QNetworkCookieJar::~QNetworkCookieJar () [virtual]

Destroys this cookie jar object and discards all cookies stored in it. Cookies are not saved to disk in the QNetworkCookieJar default implementation.

If you need to save the cookies to disk, you have to derive from QNetworkCookieJar and save the cookies to disk yourself.

QList<QNetworkCookie> QNetworkCookieJar::allCookies () const [protected]

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.

See also setAllCookies() and cookiesForUrl().

QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl ( const QUrl & url ) const [virtual]

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 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 cookiesForUrl().

See also setCookiesFromUrl() and QNetworkAccessManager::setCookieJar().

void QNetworkCookieJar::setAllCookies ( const QList<QNetworkCookie> & cookieList ) [protected]

Sets the internal list of cookies held by this cookie jar to be cookieList. This function is suitable for derived classes to implement loading cookies from permanent storage, or their own cookie acceptance policies by reimplementing setCookiesFromUrl().

See also allCookies() and setCookiesFromUrl().

bool QNetworkCookieJar::setCookiesFromUrl ( const QList<QNetworkCookie> & cookieList, const QUrl & url ) [virtual]

Adds the cookies in the list cookieList to this cookie jar. Default values for path and domain are taken from the url object.

Returns true if one or more cookies are set for url, otherwise false.

If a cookie already exists in the cookie jar, it will be overridden by those in cookieList.

The default 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 setCookiesFromUrl().

Also, QNetworkCookieJar does not have a maximum cookie jar size. Reimplement this function to discard older cookies to create room for new ones.

See also cookiesForUrl() and QNetworkAccessManager::setCookieJar().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.8
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web