1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtNetwork module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QNETWORKREQUEST_H
|
---|
43 | #define QNETWORKREQUEST_H
|
---|
44 |
|
---|
45 | #include <QtCore/QSharedDataPointer>
|
---|
46 | #include <QtCore/QString>
|
---|
47 | #include <QtCore/QUrl>
|
---|
48 | #include <QtCore/QVariant>
|
---|
49 |
|
---|
50 | QT_BEGIN_HEADER
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | QT_MODULE(Network)
|
---|
55 |
|
---|
56 | class QSslConfiguration;
|
---|
57 |
|
---|
58 | class QNetworkRequestPrivate;
|
---|
59 | class Q_NETWORK_EXPORT QNetworkRequest
|
---|
60 | {
|
---|
61 | public:
|
---|
62 | enum KnownHeaders {
|
---|
63 | ContentTypeHeader,
|
---|
64 | ContentLengthHeader,
|
---|
65 | LocationHeader,
|
---|
66 | LastModifiedHeader,
|
---|
67 | CookieHeader,
|
---|
68 | SetCookieHeader
|
---|
69 | };
|
---|
70 | enum Attribute {
|
---|
71 | HttpStatusCodeAttribute,
|
---|
72 | HttpReasonPhraseAttribute,
|
---|
73 | RedirectionTargetAttribute,
|
---|
74 | ConnectionEncryptedAttribute,
|
---|
75 | CacheLoadControlAttribute,
|
---|
76 | CacheSaveControlAttribute,
|
---|
77 | SourceIsFromCacheAttribute,
|
---|
78 | DoNotBufferUploadDataAttribute,
|
---|
79 | HttpPipeliningAllowedAttribute,
|
---|
80 | HttpPipeliningWasUsedAttribute,
|
---|
81 | CustomVerbAttribute,
|
---|
82 | CookieLoadControlAttribute,
|
---|
83 | AuthenticationReuseAttribute,
|
---|
84 | CookieSaveControlAttribute,
|
---|
85 | MaximumDownloadBufferSizeAttribute, // internal
|
---|
86 | DownloadBufferAttribute, // internal
|
---|
87 |
|
---|
88 | // (DownloadBufferAttribute + 1) is reserved internal for QSynchronousHttpNetworkReply
|
---|
89 | // add the enum in 4.8
|
---|
90 |
|
---|
91 | User = 1000,
|
---|
92 | UserMax = 32767
|
---|
93 | };
|
---|
94 | enum CacheLoadControl {
|
---|
95 | AlwaysNetwork,
|
---|
96 | PreferNetwork,
|
---|
97 | PreferCache,
|
---|
98 | AlwaysCache
|
---|
99 | };
|
---|
100 | enum LoadControl {
|
---|
101 | Automatic = 0,
|
---|
102 | Manual
|
---|
103 | };
|
---|
104 |
|
---|
105 | enum Priority {
|
---|
106 | HighPriority = 1,
|
---|
107 | NormalPriority = 3,
|
---|
108 | LowPriority = 5
|
---|
109 | };
|
---|
110 |
|
---|
111 | explicit QNetworkRequest(const QUrl &url = QUrl());
|
---|
112 | QNetworkRequest(const QNetworkRequest &other);
|
---|
113 | ~QNetworkRequest();
|
---|
114 | QNetworkRequest &operator=(const QNetworkRequest &other);
|
---|
115 |
|
---|
116 | bool operator==(const QNetworkRequest &other) const;
|
---|
117 | inline bool operator!=(const QNetworkRequest &other) const
|
---|
118 | { return !operator==(other); }
|
---|
119 |
|
---|
120 | QUrl url() const;
|
---|
121 | void setUrl(const QUrl &url);
|
---|
122 |
|
---|
123 | // "cooked" headers
|
---|
124 | QVariant header(KnownHeaders header) const;
|
---|
125 | void setHeader(KnownHeaders header, const QVariant &value);
|
---|
126 |
|
---|
127 | // raw headers:
|
---|
128 | bool hasRawHeader(const QByteArray &headerName) const;
|
---|
129 | QList<QByteArray> rawHeaderList() const;
|
---|
130 | QByteArray rawHeader(const QByteArray &headerName) const;
|
---|
131 | void setRawHeader(const QByteArray &headerName, const QByteArray &value);
|
---|
132 |
|
---|
133 | // attributes
|
---|
134 | QVariant attribute(Attribute code, const QVariant &defaultValue = QVariant()) const;
|
---|
135 | void setAttribute(Attribute code, const QVariant &value);
|
---|
136 |
|
---|
137 | #ifndef QT_NO_OPENSSL
|
---|
138 | QSslConfiguration sslConfiguration() const;
|
---|
139 | void setSslConfiguration(const QSslConfiguration &configuration);
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | void setOriginatingObject(QObject *object);
|
---|
143 | QObject *originatingObject() const;
|
---|
144 |
|
---|
145 | Priority priority() const;
|
---|
146 | void setPriority(Priority priority);
|
---|
147 |
|
---|
148 | private:
|
---|
149 | QSharedDataPointer<QNetworkRequestPrivate> d;
|
---|
150 | friend class QNetworkRequestPrivate;
|
---|
151 | };
|
---|
152 |
|
---|
153 | QT_END_NAMESPACE
|
---|
154 |
|
---|
155 | Q_DECLARE_METATYPE(QNetworkRequest)
|
---|
156 |
|
---|
157 | QT_END_HEADER
|
---|
158 |
|
---|
159 | #endif
|
---|