[neon/kde/knewstuff/Neon/release] debian/patches: add patch reocmmended by maintainer

Jonathan Riddell null at kde.org
Sat Oct 2 12:07:15 BST 2021


Git commit afcdc2e9d9f4c7a5de681be1e5919eb13a4f330a by Jonathan Riddell.
Committed on 02/10/2021 at 11:06.
Pushed by jriddell into branch 'Neon/release'.

add patch reocmmended by maintainer

M  +1    -0    debian/patches/series
A  +46   -0    debian/patches/user-agent.diff

https://invent.kde.org/neon/kde/knewstuff/commit/afcdc2e9d9f4c7a5de681be1e5919eb13a4f330a

diff --git a/debian/patches/series b/debian/patches/series
index 0c7c472..450bd89 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 constructor2.diff
+user-agent.diff
diff --git a/debian/patches/user-agent.diff b/debian/patches/user-agent.diff
new file mode 100644
index 0000000..6aad124
--- /dev/null
+++ b/debian/patches/user-agent.diff
@@ -0,0 +1,46 @@
+diff --git a/src/core/jobs/httpworker.cpp b/src/core/jobs/httpworker.cpp
+index 4c218b080d9d83c57e82064be4b534e0744c132a..b81edd2db630cacdbcf7123847bae2da67d6ae22 100644
+--- a/src/core/jobs/httpworker.cpp
++++ b/src/core/jobs/httpworker.cpp
+@@ -7,7 +7,9 @@
+ #include "httpworker.h"
+ 
+ #include "knewstuffcore_debug.h"
++#include "knewstuffcore_version.h"
+ 
++#include <QCoreApplication>
+ #include <QFile>
+ #include <QMutex>
+ #include <QMutexLocker>
+@@ -93,6 +95,15 @@ void HTTPWorker::setUrl(const QUrl &url)
+     d->source = url;
+ }
+ 
++static void addUserAgent(QNetworkRequest &request)
++{
++    QString agentHeader = QStringLiteral("KNewStuff/%1").arg(QLatin1String(KNEWSTUFFCORE_VERSION_STRING));
++    if (QCoreApplication::instance()) {
++        agentHeader += QStringLiteral("-%1/%2").arg(QCoreApplication::instance()->applicationName(), QCoreApplication::instance()->applicationVersion());
++    }
++    request.setHeader(QNetworkRequest::UserAgentHeader, agentHeader);
++}
++
+ void HTTPWorker::startRequest()
+ {
+     if (d->reply) {
+@@ -101,6 +112,7 @@ void HTTPWorker::startRequest()
+     }
+ 
+     QNetworkRequest request(d->source);
++    addUserAgent(request);
+     d->reply = s_httpWorkerNAM->get(request);
+     connect(d->reply, &QNetworkReply::readyRead, this, &HTTPWorker::handleReadyRead);
+     connect(d->reply, &QNetworkReply::finished, this, &HTTPWorker::handleFinished);
+@@ -144,6 +156,7 @@ void HTTPWorker::handleFinished()
+                                    << d->reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+             d->reply->deleteLater();
+             QNetworkRequest request(d->redirectUrl);
++            addUserAgent(request);
+             d->reply = s_httpWorkerNAM->get(request);
+             connect(d->reply, &QNetworkReply::readyRead, this, &HTTPWorker::handleReadyRead);
+             connect(d->reply, &QNetworkReply::finished, this, &HTTPWorker::handleFinished);


More information about the Neon-commits mailing list