qnetworkreplydataimpl.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkreplydataimpl.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qnetworkreplydataimpl_p.h"-
35#include "private/qdataurl_p.h"-
36#include <QtCore/QCoreApplication>-
37#include <QtCore/QMetaObject>-
38-
39QT_BEGIN_NAMESPACE-
40-
41QNetworkReplyDataImplPrivate::QNetworkReplyDataImplPrivate()-
42 : QNetworkReplyPrivate()-
43{-
44}
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
30
45-
46QNetworkReplyDataImplPrivate::~QNetworkReplyDataImplPrivate()-
47{-
48}-
49-
50QNetworkReplyDataImpl::~QNetworkReplyDataImpl()-
51{-
52}-
53-
54QNetworkReplyDataImpl::QNetworkReplyDataImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)-
55 : QNetworkReply(*new QNetworkReplyDataImplPrivate(), parent)-
56{-
57 Q_D(QNetworkReplyDataImpl);-
58 setRequest(req);-
59 setUrl(req.url());-
60 setOperation(op);-
61 setFinished(true);-
62 QNetworkReply::open(QIODevice::ReadOnly);-
63-
64 QUrl url = req.url();-
65 QString mimeType;-
66 QByteArray payload;-
67 if (qDecodeDataUrl(url, mimeType, payload)) {
qDecodeDataUrl...Type, payload)Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-30
68 qint64 size = payload.size();-
69 setHeader(QNetworkRequest::ContentTypeHeader, mimeType);-
70 setHeader(QNetworkRequest::ContentLengthHeader, size);-
71 QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);-
72-
73 d->decodedData.setData(payload);-
74 d->decodedData.open(QIODevice::ReadOnly);-
75-
76 QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,-
77 Q_ARG(qint64,size), Q_ARG(qint64, size));-
78 QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);-
79 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
80 } else {
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
30
81 // something wrong with this URI-
82 const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",-
83 "Invalid URI: %1").arg(url.toString());-
84 setError(QNetworkReply::ProtocolFailure, msg);-
85 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
86 Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolFailure));-
87 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
88 }
never executed: end of block
0
89}-
90-
91void QNetworkReplyDataImpl::close()-
92{-
93 QNetworkReply::close();-
94}
never executed: end of block
0
95-
96void QNetworkReplyDataImpl::abort()-
97{-
98 QNetworkReply::close();-
99}
never executed: end of block
0
100-
101qint64 QNetworkReplyDataImpl::bytesAvailable() const-
102{-
103 Q_D(const QNetworkReplyDataImpl);-
104 return QNetworkReply::bytesAvailable() + d->decodedData.bytesAvailable();
executed 8 times by 1 test: return QNetworkReply::bytesAvailable() + d->decodedData.bytesAvailable();
Executed by:
  • tst_QNetworkReply
8
105}-
106-
107bool QNetworkReplyDataImpl::isSequential () const-
108{-
109 return true;
executed 29 times by 1 test: return true;
Executed by:
  • tst_QNetworkReply
29
110}-
111-
112qint64 QNetworkReplyDataImpl::size() const-
113{-
114 Q_D(const QNetworkReplyDataImpl);-
115 return d->decodedData.size();
never executed: return d->decodedData.size();
0
116}-
117-
118/*!-
119 \internal-
120*/-
121qint64 QNetworkReplyDataImpl::readData(char *data, qint64 maxlen)-
122{-
123 Q_D(QNetworkReplyDataImpl);-
124-
125 // TODO idea:-
126 // Instead of decoding the whole data into new memory, we could decode on demand.-
127 // Note that this might be tricky to do.-
128-
129 return d->decodedData.read(data, maxlen);
executed 47 times by 1 test: return d->decodedData.read(data, maxlen);
Executed by:
  • tst_QNetworkReply
47
130}-
131-
132-
133QT_END_NAMESPACE-
134-
135#include "moc_qnetworkreplydataimpl_p.cpp"-
136-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9