~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the test suite of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
 
 
43
#include <QtTest/QtTest>
 
44
#include <QtCore/QUrl>
 
45
#include <QtNetwork/QNetworkRequest>
 
46
#include <QtNetwork/QNetworkCookie>
 
47
 
 
48
Q_DECLARE_METATYPE(QNetworkRequest::KnownHeaders)
 
49
 
 
50
class tst_QNetworkRequest: public QObject
 
51
{
 
52
    Q_OBJECT
 
53
 
 
54
private slots:
 
55
    void ctor_data();
 
56
    void ctor();
 
57
    void setUrl_data();
 
58
    void setUrl();
 
59
    void setRawHeader_data();
 
60
    void setRawHeader();
 
61
    void rawHeaderList_data();
 
62
    void rawHeaderList();
 
63
    void setHeader_data();
 
64
    void setHeader();
 
65
    void rawHeaderParsing_data();
 
66
    void rawHeaderParsing();
 
67
    void originatingObject();
 
68
 
 
69
    void removeHeader();
 
70
};
 
71
 
 
72
QT_BEGIN_NAMESPACE
 
73
 
 
74
namespace QTest {
 
75
    template<>
 
76
    char *toString(const QNetworkCookie &cookie)
 
77
    {
 
78
        return qstrdup(cookie.toRawForm());
 
79
    }
 
80
 
 
81
    template<>
 
82
    char *toString(const QList<QNetworkCookie> &list)
 
83
    {
 
84
        QString result = "QList(";
 
85
        bool first = true;
 
86
        foreach (QNetworkCookie cookie, list) {
 
87
            if (!first)
 
88
                result += ", ";
 
89
            first = false;
 
90
            result += QString::fromLatin1("QNetworkCookie(%1)").arg(QLatin1String(cookie.toRawForm()));
 
91
        }
 
92
 
 
93
        return qstrdup(result.append(')').toLocal8Bit());
 
94
    }
 
95
}
 
96
 
 
97
QT_END_NAMESPACE
 
98
 
 
99
void tst_QNetworkRequest::ctor_data()
 
100
{
 
101
    QTest::addColumn<QUrl>("url");
 
102
 
 
103
    QTest::newRow("nothing") << QUrl();
 
104
    QTest::newRow("empty") << QUrl();
 
105
    QTest::newRow("http") << QUrl("http://qt.nokia.com");
 
106
}
 
107
 
 
108
void tst_QNetworkRequest::ctor()
 
109
{
 
110
    QFETCH(QUrl, url);
 
111
 
 
112
    if (qstrcmp(QTest::currentDataTag(), "nothing") == 0) {
 
113
        QNetworkRequest request;
 
114
        QCOMPARE(request.url(), url);
 
115
    } else {
 
116
        QNetworkRequest request(url);
 
117
        QCOMPARE(request.url(), url);
 
118
    }
 
119
}
 
120
 
 
121
void tst_QNetworkRequest::setUrl_data()
 
122
{
 
123
    ctor_data();
 
124
}
 
125
 
 
126
void tst_QNetworkRequest::setUrl()
 
127
{
 
128
    QFETCH(QUrl, url);
 
129
    QNetworkRequest request;
 
130
 
 
131
    if (qstrcmp(QTest::currentDataTag(), "nothing") != 0)
 
132
        request.setUrl(url);
 
133
 
 
134
    QCOMPARE(request.url(), url);
 
135
}
 
136
 
 
137
void tst_QNetworkRequest::setRawHeader_data()
 
138
{
 
139
    QTest::addColumn<QByteArray>("header");
 
140
    QTest::addColumn<QByteArray>("value");
 
141
    QTest::addColumn<QByteArray>("headerToGet");
 
142
    QTest::addColumn<QByteArray>("expectedValue");
 
143
    QTest::addColumn<bool>("hasHeader");
 
144
 
 
145
    QTest::newRow("null-header") << QByteArray() << QByteArray("abc")
 
146
                                 << QByteArray() << QByteArray() << false;
 
147
    QTest::newRow("empty-header") << QByteArray("") << QByteArray("abc")
 
148
                                  << QByteArray("") << QByteArray() << false;
 
149
    QTest::newRow("null-value") << QByteArray("foo") << QByteArray()
 
150
                                << QByteArray("foo") << QByteArray() << false;
 
151
    QTest::newRow("empty-value") << QByteArray("foo") << QByteArray("")
 
152
                                 << QByteArray("foo") << QByteArray("") << true;
 
153
    QTest::newRow("empty-value-vs-null") << QByteArray("foo") << QByteArray("")
 
154
                                         << QByteArray("foo") << QByteArray() << true;
 
155
 
 
156
    QTest::newRow("UPPER-UPPER") << QByteArray("FOO") << QByteArray("abc")
 
157
                                 << QByteArray("FOO") << QByteArray("abc") << true;
 
158
    QTest::newRow("UPPER-Mixed") << QByteArray("FOO") << QByteArray("abc")
 
159
                                 << QByteArray("Foo") << QByteArray("abc") << true;
 
160
    QTest::newRow("UPPER-lower") << QByteArray("FOO") << QByteArray("abc")
 
161
                                 << QByteArray("foo") << QByteArray("abc") << true;
 
162
    QTest::newRow("Mixed-UPPER") << QByteArray("Foo") << QByteArray("abc")
 
163
                                 << QByteArray("FOO") << QByteArray("abc") << true;
 
164
    QTest::newRow("Mixed-Mixed") << QByteArray("Foo") << QByteArray("abc")
 
165
                                 << QByteArray("Foo") << QByteArray("abc") << true;
 
166
    QTest::newRow("Mixed-lower") << QByteArray("Foo") << QByteArray("abc")
 
167
                                 << QByteArray("foo") << QByteArray("abc") << true;
 
168
    QTest::newRow("lower-UPPER") << QByteArray("foo") << QByteArray("abc")
 
169
                                 << QByteArray("FOO") << QByteArray("abc") << true;
 
170
    QTest::newRow("lower-Mixed") << QByteArray("foo") << QByteArray("abc")
 
171
                                 << QByteArray("Foo") << QByteArray("abc") << true;
 
172
    QTest::newRow("lower-lower") << QByteArray("foo") << QByteArray("abc")
 
173
                                 << QByteArray("foo") << QByteArray("abc") << true;
 
174
}
 
175
 
 
176
void tst_QNetworkRequest::setRawHeader()
 
177
{
 
178
    QFETCH(QByteArray, header);
 
179
    QFETCH(QByteArray, value);
 
180
    QFETCH(QByteArray, headerToGet);
 
181
    QFETCH(QByteArray, expectedValue);
 
182
    QFETCH(bool, hasHeader);
 
183
 
 
184
    QNetworkRequest request;
 
185
    request.setRawHeader(header, value);
 
186
 
 
187
    QCOMPARE(request.hasRawHeader(headerToGet), hasHeader);
 
188
    QCOMPARE(request.rawHeader(headerToGet), expectedValue);
 
189
}
 
190
 
 
191
void tst_QNetworkRequest::rawHeaderList_data()
 
192
{
 
193
    QTest::addColumn<QList<QByteArray> >("set");
 
194
    QTest::addColumn<QList<QByteArray> >("expected");
 
195
 
 
196
    QTest::newRow("empty") << QList<QByteArray>() << QList<QByteArray>();
 
197
 
 
198
    QList<QByteArray> set;
 
199
    QList<QByteArray> expected;
 
200
 
 
201
    set << "foo";
 
202
    expected = set;
 
203
    QTest::newRow("one") << set << expected;
 
204
 
 
205
    set << "bar";
 
206
    expected = set;
 
207
    QTest::newRow("two") << set << expected;
 
208
 
 
209
    set.clear();
 
210
    expected.clear();
 
211
    set << "foo" << "foo";
 
212
    expected << "foo";
 
213
    QTest::newRow("repeated") << set << expected;
 
214
 
 
215
    set.clear();
 
216
    expected.clear();
 
217
    set << "foo" << "bar" << "foo";
 
218
    expected << "bar" << "foo";
 
219
    QTest::newRow("repeated-interleaved") << set << expected;
 
220
}
 
221
 
 
222
void tst_QNetworkRequest::rawHeaderList()
 
223
{
 
224
    QFETCH(QList<QByteArray>, set);
 
225
    QFETCH(QList<QByteArray>, expected);
 
226
 
 
227
    QNetworkRequest request;
 
228
    foreach (QByteArray header, set)
 
229
        request.setRawHeader(header, "a value");
 
230
 
 
231
    QList<QByteArray> got = request.rawHeaderList();
 
232
    QCOMPARE(got.size(), expected.size());
 
233
    for (int i = 0; i < got.size(); ++i)
 
234
        QCOMPARE(got.at(i), expected.at(i));
 
235
}
 
236
 
 
237
void tst_QNetworkRequest::setHeader_data()
 
238
{
 
239
    QTest::addColumn<QNetworkRequest::KnownHeaders>("cookedHeader");
 
240
    QTest::addColumn<QVariant>("cookedValue");
 
241
    QTest::addColumn<bool>("success");
 
242
    QTest::addColumn<QString>("rawHeader");
 
243
    QTest::addColumn<QString>("rawValue");
 
244
 
 
245
    QTest::newRow("Content-Type-Null") << QNetworkRequest::ContentTypeHeader << QVariant()
 
246
                                       << false << "Content-Type" << "";
 
247
    QTest::newRow("Content-Type-String") << QNetworkRequest::ContentTypeHeader << QVariant("text/html")
 
248
                                         << true
 
249
                                         << "Content-Type" << "text/html";
 
250
    QTest::newRow("Content-Type-ByteArray") << QNetworkRequest::ContentTypeHeader
 
251
                                            << QVariant("text/html") << true
 
252
                                            << "Content-Type" << "text/html";
 
253
 
 
254
    QTest::newRow("Content-Length-Int") << QNetworkRequest::ContentLengthHeader << QVariant(1)
 
255
                                        << true << "Content-Length" << "1";
 
256
    QTest::newRow("Content-Length-Int64") << QNetworkRequest::ContentLengthHeader << QVariant(qint64(1))
 
257
                                          << true << "Content-Length" << "1";
 
258
 
 
259
    QTest::newRow("Location-String") << QNetworkRequest::LocationHeader << QVariant("http://foo/with space")
 
260
                                     << true << "Location" << "http://foo/with space";
 
261
    QTest::newRow("Location-ByteArray") << QNetworkRequest::LocationHeader
 
262
                                        << QVariant("http://foo/with space")
 
263
                                        << true << "Location" << "http://foo/with space";
 
264
    QTest::newRow("Location-Url") << QNetworkRequest::LocationHeader
 
265
                                  << QVariant(QUrl("http://foo/with space"))
 
266
                                  << true << "Location" << "http://foo/with%20space";
 
267
 
 
268
    QTest::newRow("Last-Modified-Date") << QNetworkRequest::LastModifiedHeader
 
269
                                        << QVariant(QDate(2007, 11, 01))
 
270
                                        << true << "Last-Modified"
 
271
                                        << "Thu, 01 Nov 2007 00:00:00 GMT";
 
272
    QTest::newRow("Last-Modified-DateTime") << QNetworkRequest::LastModifiedHeader
 
273
                                            << QVariant(QDateTime(QDate(2007, 11, 01),
 
274
                                                                  QTime(18, 8, 30),
 
275
                                                                  Qt::UTC))
 
276
                                            << true << "Last-Modified"
 
277
                                            << "Thu, 01 Nov 2007 18:08:30 GMT";
 
278
 
 
279
    QNetworkCookie cookie;
 
280
    cookie.setName("a");
 
281
    cookie.setValue("b");
 
282
    QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader
 
283
                              << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
284
                              << true << "Cookie"
 
285
                              << "a=b";
 
286
    QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader
 
287
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
288
                                 << true << "Set-Cookie"
 
289
                                 << "a=b";
 
290
 
 
291
    cookie.setPath("/");
 
292
    QTest::newRow("Cookie-2") << QNetworkRequest::CookieHeader
 
293
                              << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
294
                              << true << "Cookie"
 
295
                              << "a=b";
 
296
    QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader
 
297
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
298
                                 << true << "Set-Cookie"
 
299
                                 << "a=b; path=/";
 
300
 
 
301
    QNetworkCookie cookie2;
 
302
    cookie2.setName("c");
 
303
    cookie2.setValue("d");
 
304
    QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader
 
305
                              << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
 
306
                              << true << "Cookie"
 
307
                              << "a=b; c=d";
 
308
    QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader
 
309
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
 
310
                                 << true << "Set-Cookie"
 
311
                                 << "a=b; path=/, c=d";
 
312
}
 
313
 
 
314
void tst_QNetworkRequest::setHeader()
 
315
{
 
316
    QFETCH(QNetworkRequest::KnownHeaders, cookedHeader);
 
317
    QFETCH(QVariant, cookedValue);
 
318
    QFETCH(bool, success);
 
319
    QFETCH(QString, rawHeader);
 
320
    QFETCH(QString, rawValue);
 
321
 
 
322
    QNetworkRequest request;
 
323
    request.setHeader(cookedHeader, cookedValue);
 
324
 
 
325
    QCOMPARE(request.header(cookedHeader).isNull(), !success);
 
326
    QCOMPARE(request.hasRawHeader(rawHeader.toLatin1()), success);
 
327
    QCOMPARE(request.rawHeader(rawHeader.toLatin1()).isEmpty(), !success);
 
328
 
 
329
    if (success) {
 
330
        QCOMPARE(request.header(cookedHeader), cookedValue);
 
331
        QCOMPARE(QString(request.rawHeader(rawHeader.toLatin1())), rawValue);
 
332
    }
 
333
}
 
334
 
 
335
void tst_QNetworkRequest::rawHeaderParsing_data()
 
336
{
 
337
    QTest::addColumn<QNetworkRequest::KnownHeaders>("cookedHeader");
 
338
    QTest::addColumn<QVariant>("cookedValue");
 
339
    QTest::addColumn<bool>("success");
 
340
    QTest::addColumn<QString>("rawHeader");
 
341
    QTest::addColumn<QString>("rawValue");
 
342
 
 
343
    QTest::newRow("Content-Type") << QNetworkRequest::ContentTypeHeader << QVariant("text/html")
 
344
                                  << true
 
345
                                  << "Content-Type" << "text/html";
 
346
    QTest::newRow("Content-Length") << QNetworkRequest::ContentLengthHeader << QVariant(qint64(1))
 
347
                                    << true << "Content-Length" << " 1 ";
 
348
    QTest::newRow("Location") << QNetworkRequest::LocationHeader
 
349
                              << QVariant(QUrl("http://foo/with space"))
 
350
                              << true << "Location" << "http://foo/with%20space";
 
351
    QTest::newRow("Last-Modified-RFC1123") << QNetworkRequest::LastModifiedHeader
 
352
                                           << QVariant(QDateTime(QDate(1994, 11, 06),
 
353
                                                                 QTime(8, 49, 37),
 
354
                                                                 Qt::UTC))
 
355
                                           << true << "Last-Modified"
 
356
                                           << "Sun, 06 Nov 1994 08:49:37 GMT";
 
357
    QTest::newRow("Last-Modified-RFC850") << QNetworkRequest::LastModifiedHeader
 
358
                                           << QVariant(QDateTime(QDate(1994, 11, 06),
 
359
                                                                 QTime(8, 49, 37),
 
360
                                                                 Qt::UTC))
 
361
                                           << true << "Last-Modified"
 
362
                                           << "Sunday, 06-Nov-94 08:49:37 GMT";
 
363
    QTest::newRow("Last-Modified-asctime") << QNetworkRequest::LastModifiedHeader
 
364
                                           << QVariant(QDateTime(QDate(1994, 11, 06),
 
365
                                                                 QTime(8, 49, 37),
 
366
                                                                 Qt::UTC))
 
367
                                           << true << "Last-Modified"
 
368
                                           << "Sun Nov  6 08:49:37 1994";
 
369
 
 
370
    QTest::newRow("Content-Length-invalid1") << QNetworkRequest::ContentLengthHeader << QVariant()
 
371
                                             << false << "Content-Length" << "1a";
 
372
    QTest::newRow("Content-Length-invalid2") << QNetworkRequest::ContentLengthHeader << QVariant()
 
373
                                             << false << "Content-Length" << "a";
 
374
 
 
375
 
 
376
    QTest::newRow("Location-invalid1") << QNetworkRequest::LocationHeader << QVariant() << false
 
377
                                       << "Location" << "abc";
 
378
    QTest::newRow("Location-invalid2") << QNetworkRequest::LocationHeader << QVariant() << false
 
379
                                       << "Location" << "1http://foo";
 
380
    QTest::newRow("Location-invalid3") << QNetworkRequest::LocationHeader << QVariant() << false
 
381
                                       << "Location" << "http://foo/%gg";
 
382
 
 
383
    // don't test for invalid dates because we may want to support broken servers in the future
 
384
 
 
385
    QNetworkCookie cookie;
 
386
    cookie.setName("a");
 
387
    cookie.setValue("b");
 
388
    QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader
 
389
                              << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
390
                              << true << "Cookie"
 
391
                              << "a=b";
 
392
    QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader
 
393
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
394
                                 << true << "Set-Cookie"
 
395
                                 << "a=b";
 
396
 
 
397
    cookie.setPath("/");
 
398
    QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader
 
399
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie)
 
400
                                 << true << "Set-Cookie"
 
401
                                 << "a=b; path=/";
 
402
 
 
403
    QNetworkCookie cookie2;
 
404
    cookie.setPath("");
 
405
    cookie2.setName("c");
 
406
    cookie2.setValue("d");
 
407
    QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader
 
408
                              << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
 
409
                              << true << "Cookie"
 
410
                              << "a=b; c=d";
 
411
    cookie.setPath("/");
 
412
    QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader
 
413
                                 << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
 
414
                                 << true << "Set-Cookie"
 
415
                                 << "a=b; path=/\nc=d";
 
416
}
 
417
 
 
418
void tst_QNetworkRequest::rawHeaderParsing()
 
419
{
 
420
    QFETCH(QNetworkRequest::KnownHeaders, cookedHeader);
 
421
    QFETCH(QVariant, cookedValue);
 
422
    QFETCH(bool, success);
 
423
    QFETCH(QString, rawHeader);
 
424
    QFETCH(QString, rawValue);
 
425
 
 
426
    QNetworkRequest request;
 
427
    request.setRawHeader(rawHeader.toLatin1(), rawValue.toLatin1());
 
428
 
 
429
    // even if it doesn't parse, it's as a raw header
 
430
    QVERIFY(request.hasRawHeader(rawHeader.toLatin1()));
 
431
    QVERIFY(request.hasRawHeader(rawHeader.toLower().toLatin1()));
 
432
    QCOMPARE(QString(request.rawHeader(rawHeader.toLatin1())), rawValue);
 
433
 
 
434
    QCOMPARE(request.header(cookedHeader).isNull(), !success);
 
435
    if (cookedValue.type() != QVariant::UserType)
 
436
        QCOMPARE(request.header(cookedHeader), cookedValue);
 
437
    else if (cookedValue.userType() == qMetaTypeId<QList<QNetworkCookie> >())
 
438
        QCOMPARE(qvariant_cast<QList<QNetworkCookie> >(request.header(cookedHeader)),
 
439
                 qvariant_cast<QList<QNetworkCookie> >(cookedValue));
 
440
}
 
441
 
 
442
void tst_QNetworkRequest::removeHeader()
 
443
{
 
444
    QNetworkRequest request;
 
445
 
 
446
    request.setRawHeader("Foo", "1");
 
447
    QVERIFY(request.hasRawHeader("Foo"));
 
448
    QVERIFY(request.hasRawHeader("foo"));
 
449
    request.setRawHeader("Foo", QByteArray());
 
450
    QVERIFY(!request.hasRawHeader("Foo"));
 
451
 
 
452
    // same, but remove with different capitalisation
 
453
    request.setRawHeader("Foo", "1");
 
454
    QVERIFY(request.hasRawHeader("Foo"));
 
455
    QVERIFY(request.hasRawHeader("foo"));
 
456
    request.setRawHeader("foo", QByteArray());
 
457
    QVERIFY(!request.hasRawHeader("Foo"));
 
458
 
 
459
    // same, but not the first
 
460
    request.setRawHeader("Bar", "2");
 
461
    request.setRawHeader("Foo", "1");
 
462
    QVERIFY(request.hasRawHeader("Foo"));
 
463
    QVERIFY(request.hasRawHeader("foo"));
 
464
    request.setRawHeader("foo", QByteArray());
 
465
    QVERIFY(!request.hasRawHeader("Foo"));
 
466
    QVERIFY(request.hasRawHeader("bar"));
 
467
 
 
468
    // same, but not the first nor last
 
469
    request.setRawHeader("Foo", "1");
 
470
    request.setRawHeader("Bar", "3");
 
471
    QVERIFY(request.hasRawHeader("Foo"));
 
472
    QVERIFY(request.hasRawHeader("foo"));
 
473
    request.setRawHeader("foo", QByteArray());
 
474
    QVERIFY(!request.hasRawHeader("Foo"));
 
475
    QVERIFY(request.hasRawHeader("bar"));
 
476
}
 
477
 
 
478
void tst_QNetworkRequest::originatingObject()
 
479
{
 
480
    QNetworkRequest request;
 
481
 
 
482
    QVERIFY(!request.originatingObject());
 
483
 
 
484
    {
 
485
        QObject dummy;
 
486
        request.setOriginatingObject(&dummy);
 
487
        QCOMPARE(request.originatingObject(), &dummy);
 
488
    }
 
489
 
 
490
    QVERIFY(!request.originatingObject());
 
491
}
 
492
 
 
493
QTEST_MAIN(tst_QNetworkRequest)
 
494
#include "tst_qnetworkrequest.moc"