Debian Codegraph @

Source/Network/HTTP/CQtHttpResponseHandler.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CQtHttpResponseHandler.h"
22
23
24 namespace Konclude {
25
26 namespace Network {
27
28 namespace HTTP {
29
30 CQtHttpResponseHandler::CQtHttpResponseHandler(CQtHttpRequest* request, CQtHttpResponse* response, cint64 downloadSizeLimit, bool downloadLimitCancel, CHttpTransactionManager* manager) {
31 mRequest = request;
32 mResponse = response;
33 mManager = manager;
34 mDownloadSizeLimit = downloadSizeLimit;
35 mTotalBytesReceived = 0;
36 mDownloadLimitCancel = downloadLimitCancel;
37 mAborted = false;
38 mDeleting = false;
39 }
40
41 CQtHttpRequest* CQtHttpResponseHandler::getRequest() {
42 return mRequest;
43 }
44
45 CQtHttpResponse* CQtHttpResponseHandler::getResponse() {
46 return mResponse;
47 }
48
49 void CQtHttpResponseHandler::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
50 mTotalBytesReceived = bytesReceived;
51 if (mTotalBytesReceived > mDownloadSizeLimit && !mAborted) {
52 mManager->abort(mRequest, mResponse, CHttpTransactionManager::ABORT_DOWNLOAD_SIZE_LIMIT_REACHED);
53 mAborted = true;
54 if (!mDownloadLimitCancel) {
55 mDeleting = true;
56 }
57 }
58 if (mDeleting) {
59 mResponse->getQNetworkReply()->skip(mTotalBytesReceived);
60 }
61 }
62
63
64 }; // end namespace HTTP
65
66 }; // end namespace Network
67
68 }; // end namespace Konclude
69