Qt 4.8
|
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager. More...
#include <qnetworkrequest.h>
Public Functions | |
QVariant | attribute (Attribute code, const QVariant &defaultValue=QVariant()) const |
Returns the attribute associated with the code code. More... | |
bool | hasRawHeader (const QByteArray &headerName) const |
Returns true if the raw header headerName is present in this network request. More... | |
QVariant | header (KnownHeaders header) const |
Returns the value of the known network header header if it is present in this request. More... | |
bool | operator!= (const QNetworkRequest &other) const |
Returns false if this object is not the same as other. More... | |
QNetworkRequest & | operator= (const QNetworkRequest &other) |
Creates a copy of other. More... | |
bool | operator== (const QNetworkRequest &other) const |
Returns true if this object is the same as other (i.e., if they have the same URL, same headers and same meta-data settings). More... | |
QObject * | originatingObject () const |
Returns a reference to the object that initiated this network request; returns 0 if not set or the object has been destroyed. More... | |
Priority | priority () const |
Return the priority of this request. More... | |
QNetworkRequest (const QUrl &url=QUrl()) | |
Constructs a QNetworkRequest object with url as the URL to be requested. More... | |
QNetworkRequest (const QNetworkRequest &other) | |
Creates a copy of other. More... | |
QByteArray | rawHeader (const QByteArray &headerName) const |
Returns the raw form of header headerName. More... | |
QList< QByteArray > | rawHeaderList () const |
Returns a list of all raw headers that are set in this network request. More... | |
void | setAttribute (Attribute code, const QVariant &value) |
Sets the attribute associated with code code to be value value. More... | |
void | setHeader (KnownHeaders header, const QVariant &value) |
Sets the value of the known header header to be value, overriding any previously set headers. More... | |
void | setOriginatingObject (QObject *object) |
Allows setting a reference to the object initiating the request. More... | |
void | setPriority (Priority priority) |
Set the priority of this request to priority. More... | |
void | setRawHeader (const QByteArray &headerName, const QByteArray &value) |
Sets the header headerName to be of value headerValue. More... | |
void | setSslConfiguration (const QSslConfiguration &configuration) |
Sets this network request's SSL configuration to be config. More... | |
void | setUrl (const QUrl &url) |
Sets the URL this network request is referring to to be url. More... | |
QSslConfiguration | sslConfiguration () const |
Returns this network request's SSL configuration. More... | |
QUrl | url () const |
Returns the URL this network request is referring to. More... | |
~QNetworkRequest () | |
Disposes of the QNetworkRequest object. More... | |
Properties | |
QSharedDataPointer< QNetworkRequestPrivate > | d |
Friends | |
class | QNetworkRequestPrivate |
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
QNetworkRequest is part of the Network Access API and is the class holding the information necessary to send a request over the network. It contains a URL and some ancillary information that can be used to modify the request.
Definition at line 59 of file qnetworkrequest.h.
Attribute codes for the QNetworkRequest and QNetworkReply.
Attributes are extra meta-data that are used to control the behavior of the request and to pass further information from the reply back to the application. Attributes are also extensible, allowing custom implementations to pass custom values.
The following table explains what the default attribute codes are, the QVariant types associated, the default value if said attribute is missing and whether it's used in requests or replies.
Definition at line 71 of file qnetworkrequest.h.
Controls the caching mechanism of QNetworkAccessManager.
Enumerator | |
---|---|
AlwaysNetwork | |
PreferNetwork | |
PreferCache | |
AlwaysCache |
Definition at line 93 of file qnetworkrequest.h.
List of known header types that QNetworkRequest parses.
Each known header is also represented in raw form with its full HTTP name.
Enumerator | |
---|---|
ContentTypeHeader | |
ContentLengthHeader | |
LocationHeader | |
LastModifiedHeader | |
CookieHeader | |
SetCookieHeader | |
ContentDispositionHeader |
Definition at line 62 of file qnetworkrequest.h.
Indicates if an aspect of the request's loading mechanism has been manually overridden, e.
g. by QtWebKit.
\arg \b Automatic default value: indicates default behaviour. \arg \b Manual indicates behaviour has been manually overridden.
Enumerator | |
---|---|
Automatic | |
Manual |
Definition at line 99 of file qnetworkrequest.h.
This enum lists the possible network request priorities.
Enumerator | |
---|---|
HighPriority | |
NormalPriority | |
LowPriority |
Definition at line 104 of file qnetworkrequest.h.
Constructs a QNetworkRequest object with url as the URL to be requested.
Definition at line 342 of file qnetworkrequest.cpp.
QNetworkRequest::QNetworkRequest | ( | const QNetworkRequest & | other | ) |
QNetworkRequest::~QNetworkRequest | ( | ) |
QVariant QNetworkRequest::attribute | ( | Attribute | code, |
const QVariant & | defaultValue = QVariant() |
||
) | const |
Returns the attribute associated with the code code.
If the attribute has not been set, it returns defaultValue.
Note: this function does not apply the defaults listed in QNetworkRequest::Attribute.
Definition at line 514 of file qnetworkrequest.cpp.
Referenced by QNetworkAccessManagerPrivate::authenticationRequired(), QNetworkReplyImplPrivate::createCache(), QNetworkAccessManager::createRequest(), QNetworkReplyImplPrivate::getDownloadBuffer(), QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), QNetworkReplyImplPrivate::metaDataChanged(), QNetworkAccessHttpBackend::postRequest(), and QNetworkReplyImplPrivate::setup().
bool QNetworkRequest::hasRawHeader | ( | const QByteArray & | headerName | ) | const |
Returns true if the raw header headerName is present in this network request.
Definition at line 446 of file qnetworkrequest.cpp.
Referenced by QDeclarativeXMLHttpRequest::addHeader(), and QNetworkAccessManagerPrivate::prepareMultipart().
QVariant QNetworkRequest::header | ( | KnownHeaders | header | ) | const |
Returns the value of the known network header header if it is present in this request.
If it is not present, returns QVariant() (i.e., an invalid variant).
Definition at line 423 of file qnetworkrequest.cpp.
Referenced by QNetworkAccessManager::createRequest(), QNetworkAccessManagerPrivate::prepareMultipart(), QDeclarativeXMLHttpRequest::requestFromUrl(), and QNetworkReplyImplPrivate::setup().
|
inline |
Returns false if this object is not the same as other.
Definition at line 116 of file qnetworkrequest.h.
QNetworkRequest & QNetworkRequest::operator= | ( | const QNetworkRequest & | other | ) |
bool QNetworkRequest::operator== | ( | const QNetworkRequest & | other | ) | const |
Returns true if this object is the same as other (i.e., if they have the same URL, same headers and same meta-data settings).
Definition at line 371 of file qnetworkrequest.cpp.
QObject * QNetworkRequest::originatingObject | ( | ) | const |
Returns a reference to the object that initiated this network request; returns 0 if not set or the object has been destroyed.
Definition at line 601 of file qnetworkrequest.cpp.
QNetworkRequest::Priority QNetworkRequest::priority | ( | ) | const |
Return the priority of this request.
Definition at line 616 of file qnetworkrequest.cpp.
Referenced by setPriority().
QByteArray QNetworkRequest::rawHeader | ( | const QByteArray & | headerName | ) | const |
Returns the raw form of header headerName.
If no such header is present, an empty QByteArray is returned, which may be indistinguishable from a header that is present but has no content (use hasRawHeader() to find out if the header exists or not).
Raw headers can be set with setRawHeader() or with setHeader().
Definition at line 461 of file qnetworkrequest.cpp.
Referenced by QDeclarativeXMLHttpRequest::addHeader(), QNetworkAccessHttpBackend::canResume(), and QNetworkAccessHttpBackend::postRequest().
QList< QByteArray > QNetworkRequest::rawHeaderList | ( | ) | const |
Returns a list of all raw headers that are set in this network request.
The list is in the order that the headers were set.
Definition at line 476 of file qnetworkrequest.cpp.
Referenced by QNetworkAccessHttpBackend::postRequest().
Sets the attribute associated with code code to be value value.
If the attribute is already set, the previous value is discarded. In special, if value is an invalid QVariant, the attribute is unset.
Definition at line 527 of file qnetworkrequest.cpp.
Referenced by QDeclarativeFontObject::download(), QDeclarativeAnimatedImage::load(), QDeclarativePixmapReader::networkRequestDone(), QDeclarativePixmapReader::processJob(), and QNetworkAccessManager::sendCustomRequest().
void QNetworkRequest::setHeader | ( | KnownHeaders | header, |
const QVariant & | value | ||
) |
Sets the value of the known header header to be value, overriding any previously set headers.
This operation also sets the equivalent raw HTTP header.
Definition at line 435 of file qnetworkrequest.cpp.
Referenced by QNetworkAccessManager::createRequest(), QNetworkAccessManagerPrivate::prepareMultipart(), and QDeclarativeXMLHttpRequest::requestFromUrl().
void QNetworkRequest::setOriginatingObject | ( | QObject * | object | ) |
Allows setting a reference to the object initiating the request.
For example QtWebKit sets the originating object to the QWebFrame that initiated the request.
Definition at line 584 of file qnetworkrequest.cpp.
void QNetworkRequest::setPriority | ( | Priority | priority | ) |
Set the priority of this request to priority.
Definition at line 649 of file qnetworkrequest.cpp.
void QNetworkRequest::setRawHeader | ( | const QByteArray & | headerName, |
const QByteArray & | headerValue | ||
) |
Sets the header headerName to be of value headerValue.
If headerName corresponds to a known header (see QNetworkRequest::KnownHeaders), the raw format will be parsed and the corresponding "cooked" header will be set as well.
For example:
will also set the known header LastModifiedHeader to be the QDateTime object of the parsed date.
Note: setting the same header twice overrides the previous setting. To accomplish the behaviour of multiple HTTP headers of the same name, you should concatenate the two values, separating them with a comma (",") and set one single raw header.
Definition at line 500 of file qnetworkrequest.cpp.
Referenced by QDeclarativeXMLHttpRequest::addHeader(), QNetworkAccessManagerPrivate::prepareMultipart(), and QDeclarativeXmlListModel::reload().
void QNetworkRequest::setSslConfiguration | ( | const QSslConfiguration & | config | ) |
Sets this network request's SSL configuration to be config.
The settings that apply are the private key, the local certificate, the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable), the CA certificates and the ciphers that the SSL backend is allowed to use.
By default, no SSL configuration is set, which allows the backends to choose freely what configuration is best for them.
Definition at line 561 of file qnetworkrequest.cpp.
void QNetworkRequest::setUrl | ( | const QUrl & | url | ) |
Sets the URL this network request is referring to to be url.
Definition at line 411 of file qnetworkrequest.cpp.
Referenced by QDeclarativeInclude::finished(), QDeclarativeInclude::QDeclarativeInclude(), and QDeclarativeXMLHttpRequest::requestFromUrl().
QSslConfiguration QNetworkRequest::sslConfiguration | ( | ) | const |
Returns this network request's SSL configuration.
By default, no SSL settings are specified.
Definition at line 542 of file qnetworkrequest.cpp.
Referenced by QNetworkAccessManager::createRequest(), QNetworkAccessHttpBackend::fetchSslConfiguration(), and QNetworkAccessHttpBackend::postRequest().
QUrl QNetworkRequest::url | ( | ) | const |
Returns the URL this network request is referring to.
Definition at line 401 of file qnetworkrequest.cpp.
Referenced by QNetworkReplyImplPrivate::_q_networkSessionConnected(), QNetworkAccessFileBackendFactory::create(), QNetworkAccessFtpBackendFactory::create(), QNetworkAccessHttpBackendFactory::create(), QPatternist::URILoader::createRequest(), QNetworkAccessManager::createRequest(), QNetworkAccessHttpBackend::postRequest(), QDisabledNetworkReply::QDisabledNetworkReply(), QNetworkReplyDataImpl::QNetworkReplyDataImpl(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QNetworkRequest(), QNetworkReplyImplPrivate::setup(), and setUrl().
|
friend |
Definition at line 149 of file qnetworkrequest.h.
|
private |
Definition at line 148 of file qnetworkrequest.h.
Referenced by attribute(), hasRawHeader(), header(), operator=(), operator==(), originatingObject(), priority(), QNetworkRequest(), rawHeader(), rawHeaderList(), setAttribute(), setHeader(), setOriginatingObject(), setPriority(), setRawHeader(), setSslConfiguration(), setUrl(), sslConfiguration(), url(), and ~QNetworkRequest().