File indexing completed on 2024-10-06 07:38:13

0001 // SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #include "networkaccessmanagerfactory.h"
0005 
0006 #include <QNetworkAccessManager>
0007 #include <QNetworkDiskCache>
0008 #include <QStandardPaths>
0009 #include <QThread>
0010 
0011 QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
0012 {
0013     auto nam = new QNetworkAccessManager(parent);
0014 
0015     nam->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
0016 
0017     nam->enableStrictTransportSecurityStore(true, QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/hsts/"));
0018     nam->setStrictTransportSecurityEnabled(true);
0019 
0020     auto namDiskCache = new QNetworkDiskCache(nam);
0021     namDiskCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/nam/"));
0022     nam->setCache(namDiskCache);
0023 
0024     return nam;
0025 }