Qt 4.8
|
The QNetworkAccessManager class allows the application to send network requests and receive replies. More...
#include <qnetworkaccessmanager.h>
Public Types | |
enum | NetworkAccessibility { UnknownAccessibility = -1, NotAccessible = 0, Accessible = 1 } |
Indicates whether the network is accessible via this network access manager. More... | |
enum | Operation { HeadOperation = 1, GetOperation, PutOperation, PostOperation, DeleteOperation, CustomOperation, UnknownOperation = 0 } |
Indicates the operation this reply is processing. More... | |
Signals | |
void | authenticationRequired (QNetworkReply *reply, QAuthenticator *authenticator) |
This signal is emitted whenever a final server requests authentication before it delivers the requested contents. More... | |
void | finished (QNetworkReply *reply) |
This signal is emitted whenever a pending network reply is finished. More... | |
void | networkAccessibleChanged (QNetworkAccessManager::NetworkAccessibility accessible) |
This signal is emitted when the value of the networkAccessible property changes. More... | |
void | networkSessionConnected () |
This signal is emitted when the status of the network session changes into a usable (Connected) state. More... | |
void | proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *authenticator) |
This signal is emitted whenever a proxy requests authentication and QNetworkAccessManager cannot find a valid, cached credential. More... | |
void | sslErrors (QNetworkReply *reply, const QList< QSslError > &errors) |
This signal is emitted if the SSL/TLS session encountered errors during the set up, including certificate verification errors. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QNetworkConfiguration | activeConfiguration () const |
Returns the current active network configuration. More... | |
QAbstractNetworkCache * | cache () const |
Returns the cache that is used to store data obtained from the network. More... | |
QNetworkConfiguration | configuration () const |
Returns the network configuration that will be used to create the QNetworkSession{network session} which will be used when processing network requests. More... | |
QNetworkCookieJar * | cookieJar () const |
Returns the QNetworkCookieJar that is used to store cookies obtained from the network as well as cookies that are about to be sent. More... | |
QNetworkReply * | deleteResource (const QNetworkRequest &request) |
Sends a request to delete the resource identified by the URL of request. More... | |
QNetworkReply * | get (const QNetworkRequest &request) |
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object opened for reading which emits the readyRead() signal whenever new data arrives. More... | |
QNetworkReply * | head (const QNetworkRequest &request) |
Posts a request to obtain the network headers for request and returns a new QNetworkReply object which will contain such headers. More... | |
NetworkAccessibility | networkAccessible () const |
QNetworkReply * | post (const QNetworkRequest &request, QIODevice *data) |
Sends an HTTP POST request to the destination specified by request and returns a new QNetworkReply object opened for reading that will contain the reply sent by the server. More... | |
QNetworkReply * | post (const QNetworkRequest &request, const QByteArray &data) |
Sends the contents of the data byte array to the destination specified by request. More... | |
QNetworkReply * | post (const QNetworkRequest &request, QHttpMultiPart *multiPart) |
Sends the contents of the multiPart message to the destination specified by request. More... | |
QNetworkProxy | proxy () const |
Returns the QNetworkProxy that the requests sent using this QNetworkAccessManager object will use. More... | |
QNetworkProxyFactory * | proxyFactory () const |
QNetworkReply * | put (const QNetworkRequest &request, QIODevice *data) |
Uploads the contents of data to the destination request and returnes a new QNetworkReply object that will be open for reply. More... | |
QNetworkReply * | put (const QNetworkRequest &request, const QByteArray &data) |
Sends the contents of the data byte array to the destination specified by request. More... | |
QNetworkReply * | put (const QNetworkRequest &request, QHttpMultiPart *multiPart) |
Sends the contents of the multiPart message to the destination specified by request. More... | |
QNetworkAccessManager (QObject *parent=0) | |
Constructs a QNetworkAccessManager object that is the center of the Network Access API and sets parent as the parent object. More... | |
QNetworkReply * | sendCustomRequest (const QNetworkRequest &request, const QByteArray &verb, QIODevice *data=0) |
Sends a custom request to the server identified by the URL of request. More... | |
void | setCache (QAbstractNetworkCache *cache) |
Sets the manager's network cache to be the cache specified. More... | |
void | setConfiguration (const QNetworkConfiguration &config) |
Sets the network configuration that will be used when creating the QNetworkSession{network session} to config. More... | |
void | setCookieJar (QNetworkCookieJar *cookieJar) |
Sets the manager's cookie jar to be the cookieJar specified. More... | |
void | setNetworkAccessible (NetworkAccessibility accessible) |
Overrides the reported network accessibility. More... | |
void | setProxy (const QNetworkProxy &proxy) |
Sets the proxy to be used in future requests to be proxy. More... | |
void | setProxyFactory (QNetworkProxyFactory *factory) |
Sets the proxy factory for this class to be factory. More... | |
~QNetworkAccessManager () | |
Destroys the QNetworkAccessManager object and frees up any resources. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
virtual QNetworkReply * | createRequest (Operation op, const QNetworkRequest &request, QIODevice *outgoingData=0) |
Returns a new QNetworkReply object to handle the operation op and request req. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
NetworkAccessibility | networkAccessible |
whether the network is currently accessible via this network access manager. More... | |
Friends | |
class | QNetworkAccessHttpBackend |
class | QNetworkReplyImplPrivate |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QNetworkAccessManager class allows the application to send network requests and receive replies.
The Network Access API is constructed around one QNetworkAccessManager object, which holds the common configuration and settings for the requests it sends. It contains the proxy and cache configuration, as well as the signals related to such issues, and reply signals that can be used to monitor the progress of a network operation. One QNetworkAccessManager should be enough for the whole Qt application.
Once a QNetworkAccessManager object has been created, the application can use it to send requests over the network. A group of standard functions are supplied that take a request and optional data, and each return a QNetworkReply object. The returned object is used to obtain any data returned in response to the corresponding request.
A simple download off the network could be accomplished with:
QNetworkAccessManager has an asynchronous API. When the replyFinished
slot above is called, the parameter it takes is the QNetworkReply object containing the downloaded data as well as meta-data (headers, etc.).
A more involved example, assuming the manager is already existent, can be:
With the addition of the Bearer Management API to Qt 4.7 QNetworkAccessManager gained the ability to manage network connections. QNetworkAccessManager can start the network interface if the device is offline and terminates the interface if the current process is the last one to use the uplink. Note that some platform utilize grace periods from when the last application stops using a uplink until the system actually terminates the connectivity link. Roaming is equally transparent. Any queued/pending network requests are automatically transferred to new access point.
Clients wanting to utilize this feature should not require any changes. In fact it is likely that existing platform specific connection code can simply be removed from the application.
On Symbian, processes which use this class must have the NetworkServices
platform security capability. If the client process lacks this capability, operations will result in a panic.
Platform security capabilities are added via the TARGET.CAPABILITY qmake variable.
Definition at line 72 of file qnetworkaccessmanager.h.
Indicates whether the network is accessible via this network access manager.
Enumerator | |
---|---|
UnknownAccessibility | |
NotAccessible | |
Accessible |
Definition at line 93 of file qnetworkaccessmanager.h.
Indicates the operation this reply is processing.
Enumerator | |
---|---|
HeadOperation | |
GetOperation | |
PutOperation | |
PostOperation | |
DeleteOperation | |
CustomOperation | |
UnknownOperation |
Definition at line 81 of file qnetworkaccessmanager.h.
|
explicit |
Constructs a QNetworkAccessManager object that is the center of the Network Access API and sets parent as the parent object.
Definition at line 375 of file qnetworkaccessmanager.cpp.
QNetworkAccessManager::~QNetworkAccessManager | ( | ) |
Destroys the QNetworkAccessManager object and frees up any resources.
Note that QNetworkReply objects that are returned from this class have this object set as their parents, which means that they will be deleted along with it if you don't call QObject::setParent() on them.
Definition at line 390 of file qnetworkaccessmanager.cpp.
QNetworkConfiguration QNetworkAccessManager::activeConfiguration | ( | ) | const |
Returns the current active network configuration.
If the network configuration returned by configuration() is of type QNetworkConfiguration::ServiceNetwork this function will return the current active child network configuration of that configuration. Otherwise returns the same network configuration as configuration().
Use this function to return the actual network configuration currently in use by the network session.
Definition at line 848 of file qnetworkaccessmanager.cpp.
|
signal |
This signal is emitted whenever a final server requests authentication before it delivers the requested contents.
The slot connected to this signal should fill the credentials for the contents (which can be determined by inspecting the reply object) in the authenticator object.
QNetworkAccessManager will cache the credentials internally and will send the same values if the server requires authentication again, without emitting the authenticationRequired() signal. If it rejects the credentials, this signal will be emitted again.
QAbstractNetworkCache * QNetworkAccessManager::cache | ( | ) | const |
Returns the cache that is used to store data obtained from the network.
Definition at line 509 of file qnetworkaccessmanager.cpp.
Referenced by setCache().
QNetworkConfiguration QNetworkAccessManager::configuration | ( | ) | const |
Returns the network configuration that will be used to create the QNetworkSession{network session} which will be used when processing network requests.
Definition at line 819 of file qnetworkaccessmanager.cpp.
QNetworkCookieJar * QNetworkAccessManager::cookieJar | ( | ) | const |
Returns the QNetworkCookieJar that is used to store cookies obtained from the network as well as cookies that are about to be sent.
Definition at line 552 of file qnetworkaccessmanager.cpp.
Referenced by QNetworkReplyImplPrivate::metaDataChanged().
|
protectedvirtual |
Returns a new QNetworkReply object to handle the operation op and request req.
The device outgoingData is always 0 for Get and Head requests, but is the value passed to post() and put() in those operations (the QByteArray variants will pass a QBuffer object).
The default implementation calls QNetworkCookieJar::cookiesForUrl() on the cookie jar set with setCookieJar() to obtain the cookies to be sent to the remote server.
The returned object must be in an open state.
Reimplemented in QPatternist::URILoader.
Definition at line 962 of file qnetworkaccessmanager.cpp.
Referenced by QPatternist::URILoader::createRequest(), deleteResource(), get(), head(), post(), put(), and sendCustomRequest().
QNetworkReply * QNetworkAccessManager::deleteResource | ( | const QNetworkRequest & | request | ) |
Sends a request to delete the resource identified by the URL of request.
Definition at line 770 of file qnetworkaccessmanager.cpp.
Referenced by QDeclarativeXMLHttpRequest::requestFromUrl().
|
signal |
This signal is emitted whenever a pending network reply is finished.
The reply parameter will contain a pointer to the reply that has just finished. This signal is emitted in tandem with the QNetworkReply::finished() signal.
See QNetworkReply::finished() for information on the status that the object will be in.
Referenced by QNetworkAccessManagerPrivate::postProcess().
QNetworkReply * QNetworkAccessManager::get | ( | const QNetworkRequest & | request | ) |
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object opened for reading which emits the readyRead() signal whenever new data arrives.
The contents as well as associated headers will be downloaded.
Definition at line 623 of file qnetworkaccessmanager.cpp.
Referenced by QDeclarativeFontObject::download(), QDeclarativeInclude::finished(), QDeclarativeBorderImage::load(), QDeclarativeAnimatedImage::load(), QPatternist::AccelTreeResourceLoader::load(), QDeclarativeDataLoader::load(), QDeclarativeDataLoader::networkReplyFinished(), QDeclarativePixmapReader::networkRequestDone(), QDeclarativeInclude::QDeclarativeInclude(), QDeclarativeXmlListModel::reload(), and QDeclarativeXMLHttpRequest::requestFromUrl().
QNetworkReply * QNetworkAccessManager::head | ( | const QNetworkRequest & | request | ) |
Posts a request to obtain the network headers for request and returns a new QNetworkReply object which will contain such headers.
The function is named after the HTTP request associated (HEAD).
Definition at line 608 of file qnetworkaccessmanager.cpp.
Referenced by QDeclarativeXMLHttpRequest::requestFromUrl().
NetworkAccessibility QNetworkAccessManager::networkAccessible | ( | ) | const |
|
signal |
This signal is emitted when the value of the networkAccessible property changes.
accessible is the new network accessibility.
Referenced by setNetworkAccessible().
|
signal |
This signal is emitted when the status of the network session changes into a usable (Connected) state.
It is used to signal to QNetworkReplys to start or migrate their network operation once the network session has been opened or finished roaming.
Referenced by QNetworkAccessManagerPrivate::_q_networkSessionClosed(), createRequest(), and QNetworkAccessManagerPrivate::createSession().
QNetworkReply * QNetworkAccessManager::post | ( | const QNetworkRequest & | request, |
QIODevice * | data | ||
) |
Sends an HTTP POST request to the destination specified by request and returns a new QNetworkReply object opened for reading that will contain the reply sent by the server.
The contents of the data device will be uploaded to the server.
data must be open for reading and must remain valid until the finished() signal is emitted for this reply.
Definition at line 642 of file qnetworkaccessmanager.cpp.
Referenced by post(), and QDeclarativeXMLHttpRequest::requestFromUrl().
QNetworkReply * QNetworkAccessManager::post | ( | const QNetworkRequest & | request, |
const QByteArray & | data | ||
) |
Sends the contents of the data byte array to the destination specified by request.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 656 of file qnetworkaccessmanager.cpp.
QNetworkReply * QNetworkAccessManager::post | ( | const QNetworkRequest & | request, |
QHttpMultiPart * | multiPart | ||
) |
Sends the contents of the multiPart message to the destination specified by request.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This can be used for sending MIME multipart messages over HTTP.
Definition at line 682 of file qnetworkaccessmanager.cpp.
QNetworkProxy QNetworkAccessManager::proxy | ( | ) | const |
Returns the QNetworkProxy that the requests sent using this QNetworkAccessManager object will use.
The default value for the proxy is QNetworkProxy::DefaultProxy.
Definition at line 414 of file qnetworkaccessmanager.cpp.
Referenced by QNetworkAccessManagerPrivate::proxyAuthenticationRequired(), QNetworkAccessManagerPrivate::queryProxy(), and setProxy().
|
signal |
This signal is emitted whenever a proxy requests authentication and QNetworkAccessManager cannot find a valid, cached credential.
The slot connected to this signal should fill in the credentials for the proxy proxy in the authenticator object.
QNetworkAccessManager will cache the credentials internally. The next time the proxy requests authentication, QNetworkAccessManager will automatically send the same credential without emitting the proxyAuthenticationRequired signal again.
If the proxy rejects the credentials, QNetworkAccessManager will emit the signal again.
QNetworkProxyFactory * QNetworkAccessManager::proxyFactory | ( | ) | const |
Returns the proxy factory that this QNetworkAccessManager object is using to determine the proxies to be used for requests.
Note that the pointer returned by this function is managed by QNetworkAccessManager and could be deleted at any time.
Definition at line 453 of file qnetworkaccessmanager.cpp.
Referenced by QNetworkAccessManagerPrivate::queryProxy().
QNetworkReply * QNetworkAccessManager::put | ( | const QNetworkRequest & | request, |
QIODevice * | data | ||
) |
Uploads the contents of data to the destination request and returnes a new QNetworkReply object that will be open for reply.
data must be opened for reading when this function is called and must remain valid until the finished() signal is emitted for this reply.
Whether anything will be available for reading from the returned object is protocol dependent. For HTTP, the server may send a small HTML page indicating the upload was successful (or not). Other protocols will probably have content in their replies.
Definition at line 732 of file qnetworkaccessmanager.cpp.
Referenced by put(), and QDeclarativeXMLHttpRequest::requestFromUrl().
QNetworkReply * QNetworkAccessManager::put | ( | const QNetworkRequest & | request, |
const QByteArray & | data | ||
) |
Sends the contents of the data byte array to the destination specified by request.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 746 of file qnetworkaccessmanager.cpp.
QNetworkReply * QNetworkAccessManager::put | ( | const QNetworkRequest & | request, |
QHttpMultiPart * | multiPart | ||
) |
Sends the contents of the multiPart message to the destination specified by request.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This can be used for sending MIME multipart messages over HTTP.
Definition at line 705 of file qnetworkaccessmanager.cpp.
QNetworkReply * QNetworkAccessManager::sendCustomRequest | ( | const QNetworkRequest & | request, |
const QByteArray & | verb, | ||
QIODevice * | data = 0 |
||
) |
Sends a custom request to the server identified by the URL of request.
It is the user's responsibility to send a verb to the server that is valid according to the HTTP specification.
This method provides means to send verbs other than the common ones provided via get() or post() etc., for instance sending an HTTP OPTIONS command.
If data is not empty, the contents of the data device will be uploaded to the server; in that case, data must be open for reading and must remain valid until the finished() signal is emitted for this reply.
Definition at line 942 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setCache | ( | QAbstractNetworkCache * | cache | ) |
Sets the manager's network cache to be the cache specified.
The cache is used for all requests dispatched by the manager.
Use this function to set the network cache object to a class that implements additional features, like saving the cookies to permanent storage.
QNetworkAccessManager by default does not have a set cache. Qt provides a simple disk cache, QNetworkDiskCache, which can be used.
Definition at line 534 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setConfiguration | ( | const QNetworkConfiguration & | config | ) |
Sets the network configuration that will be used when creating the QNetworkSession{network session} to config.
The network configuration is used to create and open a network session before any request that requires network access is process. If no network configuration is explicitly set via this function the network configuration returned by QNetworkConfigurationManager::defaultConfiguration() will be used.
To restore the default network configuration set the network configuration to the value returned from QNetworkConfigurationManager::defaultConfiguration().
If an invalid network configuration is set, a network session will not be created. In this case network requests will be processed regardless, but may fail. For example:
Definition at line 803 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setCookieJar | ( | QNetworkCookieJar * | cookieJar | ) |
Sets the manager's cookie jar to be the cookieJar specified.
The cookie jar is used by all requests dispatched by the manager.
Use this function to set the cookie jar object to a class that implements additional features, like saving the cookies to permanent storage.
If cookieJar is in the same thread as this QNetworkAccessManager, it will set the parent of the cookieJar so that the cookie jar is deleted when this object is deleted as well. If you want to share cookie jars between different QNetworkAccessManager objects, you may want to set the cookie jar's parent to 0 after calling this function.
QNetworkAccessManager by default does not implement any cookie policy of its own: it accepts all cookies sent by the server, as long as they are well formed and meet the minimum security requirements (cookie domain matches the request's and cookie path matches the request's). In order to implement your own security policy, override the QNetworkCookieJar::cookiesForUrl() and QNetworkCookieJar::setCookiesFromUrl() virtual functions. Those functions are called by QNetworkAccessManager when it detects a new cookie.
Definition at line 589 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setNetworkAccessible | ( | QNetworkAccessManager::NetworkAccessibility | accessible | ) |
Overrides the reported network accessibility.
If accessible is NotAccessible the reported network accessiblity will always be NotAccessible. Otherwise the reported network accessibility will reflect the actual device state.
Definition at line 873 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setProxy | ( | const QNetworkProxy & | proxy | ) |
Sets the proxy to be used in future requests to be proxy.
This does not affect requests that have already been sent. The proxyAuthenticationRequired() signal will be emitted if the proxy requests authentication.
A proxy set with this function will be used for all requests issued by QNetworkAccessManager. In some cases, it might be necessary to select different proxies depending on the type of request being sent or the destination host. If that's the case, you should consider using setProxyFactory().
Definition at line 433 of file qnetworkaccessmanager.cpp.
void QNetworkAccessManager::setProxyFactory | ( | QNetworkProxyFactory * | factory | ) |
Sets the proxy factory for this class to be factory.
A proxy factory is used to determine a more specific list of proxies to be used for a given request, instead of trying to use the same proxy value for all requests.
All queries sent by QNetworkAccessManager will have type QNetworkProxyQuery::UrlRequest.
For example, a proxy factory could apply the following rules:
The lifetime of the object factory will be managed by QNetworkAccessManager. It will delete the object when necessary.
Definition at line 490 of file qnetworkaccessmanager.cpp.
|
signal |
This signal is emitted if the SSL/TLS session encountered errors during the set up, including certificate verification errors.
The errors parameter contains the list of errors and reply is the QNetworkReply that is encountering these errors.
To indicate that the errors are not fatal and that the connection should proceed, the QNetworkReply::ignoreSslErrors() function should be called from the slot connected to this signal. If it is not called, the SSL session will be torn down before any data is exchanged (including the URL).
This signal can be used to display an error message to the user indicating that security may be compromised and display the SSL settings (see sslConfiguration() to obtain it). If the user decides to proceed after analyzing the remote certificate, the slot should call ignoreSslErrors().
Referenced by QNetworkAccessManagerPrivate::postProcess().
|
friend |
Definition at line 162 of file qnetworkaccessmanager.h.
|
friend |
Definition at line 161 of file qnetworkaccessmanager.h.
|
private |
whether the network is currently accessible via this network access manager.
Returns the current network accessibility.
If the network is NotAccessible{not accessible} the network access manager will not process any new network requests, all such requests will fail with an error. Requests with URLs with the file:// scheme will still be processed.
By default the value of this property reflects the physical state of the device. Applications may override it to disable all network requests via this network access manager by calling
Network requests can be reenabled again by calling
Definition at line 77 of file qnetworkaccessmanager.h.