QNetworkRequest 请求类

时间:2023-01-31 23:25:43

QNetworkRequest Class

Header:    #include <QNetworkRequest>
qmake:     QT += network
Since:     Qt 4.4

这个QNetworkRequest类保存了一个将被QNetworkAccessManager发送的请求.
QNetworkRequest是Network Access API的一部分,是在网络上保存着发送一个请求的必要信息.它包含一个URL和一些辅助信息,可以被用来去修改请求.
参见 QNetworkReply and QNetworkAccessManager.

公众类型(Public Types):
enum    Attribute { HttpStatusCodeAttribute, HttpReasonPhraseAttribute, RedirectionTargetAttribute, ConnectionEncryptedAttribute, ..., UserMax }
enum    CacheLoadControl { AlwaysNetwork, PreferNetwork, PreferCache, AlwaysCache }
enum    KnownHeaders { ContentDispositionHeader, ContentTypeHeader, ContentLengthHeader, LocationHeader, ..., ServerHeader }
enum    LoadControl { Automatic, Manual }
enum    Priority { HighPriority, NormalPriority, LowPriority }
共有函数(Public Functions):

QNetworkRequest(const QUrl & url = QUrl())
QNetworkRequest(const QNetworkRequest & other)
~QNetworkRequest()
QVariant    attribute(Attribute code, const QVariant & defaultValue = QVariant()) const
bool    hasRawHeader(const QByteArray & headerName) const
QVariant    header(KnownHeaders header) const
QObject *    originatingObject() const
Priority    priority() const
QByteArray    rawHeader(const QByteArray & headerName) const
QList<QByteArray>    rawHeaderList() const
void    setAttribute(Attribute code, const QVariant & value)
void    setHeader(KnownHeaders header, const QVariant & value)
void    setOriginatingObject(QObject * object)
void    setPriority(Priority priority)
void    setRawHeader(const QByteArray & headerName, const QByteArray & headerValue)
void    setSslConfiguration(const QSslConfiguration & config)
void    setUrl(const QUrl & url)
QSslConfiguration    sslConfiguration() const
void    swap(QNetworkRequest & other)
QUrl    url() const
bool    operator!=(const QNetworkRequest & other) const
QNetworkRequest &    operator=(const QNetworkRequest & other)
bool    operator==(const QNetworkRequest & other) const

成员类型文档:

enum QNetworkRequest::​Attribute
QNetworkRequest和QNetworkReply的属性代码.
属性是额外的元数据,可以被用来去控制请求的行为,以及传递从应答反馈的进一步的信息到应用程序上.属性也是可以扩展的,允许自定义实现去传递自定义值.
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.

以下的表格解释了默认的属性代码是什么