author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 2 | 56cd8111b7f7 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
|
3 |
||
4 |
This library is free software; you can redistribute it and/or |
|
5 |
modify it under the terms of the GNU Library General Public |
|
6 |
License as published by the Free Software Foundation; either |
|
7 |
version 2 of the License, or (at your option) any later version. |
|
8 |
||
9 |
This library is distributed in the hope that it will be useful, |
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 |
Library General Public License for more details. |
|
13 |
||
14 |
You should have received a copy of the GNU Library General Public License |
|
15 |
along with this library; see the file COPYING.LIB. If not, write to |
|
16 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
17 |
Boston, MA 02110-1301, USA. |
|
18 |
*/ |
|
19 |
||
20 |
#include "config.h" |
|
21 |
#include "ResourceRequest.h" |
|
22 |
||
23 |
#include <qglobal.h> |
|
24 |
#if QT_VERSION >= 0x040400 |
|
25 |
||
26 |
#include <QNetworkRequest> |
|
27 |
#include <QUrl> |
|
28 |
||
29 |
namespace WebCore { |
|
30 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
31 |
QNetworkRequest ResourceRequest::toNetworkRequest(QObject* originatingFrame) const |
0 | 32 |
{ |
33 |
QNetworkRequest request; |
|
34 |
request.setUrl(url()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
35 |
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
36 |
request.setOriginatingObject(originatingFrame); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
37 |
#endif |
0 | 38 |
|
39 |
const HTTPHeaderMap &headers = httpHeaderFields(); |
|
40 |
for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); |
|
41 |
it != end; ++it) { |
|
42 |
QByteArray name = QString(it->first).toAscii(); |
|
43 |
QByteArray value = QString(it->second).toAscii(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
44 |
// QNetworkRequest::setRawHeader() would remove the header if the value is null |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
45 |
// Make sure to set an empty header instead of null header. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
46 |
if (!value.isNull()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
47 |
request.setRawHeader(name, value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
48 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
49 |
request.setRawHeader(name, ""); |
0 | 50 |
} |
51 |
||
52 |
switch (cachePolicy()) { |
|
53 |
case ReloadIgnoringCacheData: |
|
54 |
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); |
|
55 |
break; |
|
56 |
case ReturnCacheDataElseLoad: |
|
57 |
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); |
|
58 |
break; |
|
59 |
case ReturnCacheDataDontLoad: |
|
60 |
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache); |
|
61 |
break; |
|
62 |
case UseProtocolCachePolicy: |
|
63 |
// QNetworkRequest::PreferNetwork |
|
64 |
default: |
|
65 |
break; |
|
66 |
} |
|
67 |
||
68 |
return request; |
|
69 |
} |
|
70 |
||
71 |
} |
|
72 |
||
73 |
#endif |