summaryrefslogtreecommitdiff
path: root/community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch')
-rw-r--r--community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch74
1 files changed, 74 insertions, 0 deletions
diff --git a/community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch b/community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
new file mode 100644
index 000000000..0626b7b64
--- /dev/null
+++ b/community/wkhtmltopdf/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
@@ -0,0 +1,74 @@
+From d6b406d9ec207036af807af2bee2aeb5e33827f0 Mon Sep 17 00:00:00 2001
+From: Ashish Kulkarni <kulkarni.ashish@gmail.com>
+Date: Mon, 10 Feb 2014 19:33:21 +0530
+Subject: [PATCH 1/2] fix spurious "exit with code 1 due to http error: 1xxx"
+ errors
+
+This fixes #1502 and was introduced in ce6d6cd0f0f86a5b1ff3765aaae357dfdf3be803,
+which returned errors above 1000 as a proxy for network errors. However, the
+error 5 (i.e. OperationCanceledError) was not handled, which apparently happens
+a lot due to parallel loading of resources. We thus ignore this error in the
+loader.
+
+In addition, in case the error is greater than 1000, we find out the correct
+network error and display that error instead of HTTP error 1xxx which doesn't
+exist. The trick to find out the text values for the enum was taken from:
+
+https://blog.qt.digia.com/blog/2008/10/09/coding-tip-pretty-printing-enum-values/
+---
+ src/lib/multipageloader.cc | 2 +-
+ src/lib/utilities.cc | 18 +++++++++++++++++-
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/multipageloader.cc b/src/lib/multipageloader.cc
+index 0f4e7f7..d74fa0d 100644
+--- a/src/lib/multipageloader.cc
++++ b/src/lib/multipageloader.cc
+@@ -335,7 +335,7 @@ void ResourceObject::error(const QString & str) {
+ void ResourceObject::amfinished(QNetworkReply * reply) {
+ int networkStatus = reply->error();
+ int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+- if (networkStatus > 0 || (httpStatus > 399 && httpErrorCode == 0))
++ if ((networkStatus != 0 && networkStatus != 5) || (httpStatus > 399 && httpErrorCode == 0))
+ {
+ QFileInfo fi(reply->url().toString());
+ bool mediaFile = settings::LoadPage::mediaFilesExtensions.contains(fi.completeSuffix().toLower());
+diff --git a/src/lib/utilities.cc b/src/lib/utilities.cc
+index 639aa32..4238c47 100644
+--- a/src/lib/utilities.cc
++++ b/src/lib/utilities.cc
+@@ -27,6 +27,8 @@
+ #include "utilities.hh"
+ #include <QDebug>
+ #include <QTextStream>
++#include <QMetaEnum>
++#include <QNetworkReply>
+
+ void loadSvg(QSvgRenderer * & ptr, const QString & path, const char * def, int w, int h) {
+ delete ptr;
+@@ -160,7 +162,21 @@ int handleError(bool success, int errorCode) {
+ if (ce.contains(errorCode)) c = ce[errorCode];
+ const char * m = "";
+ if (cm.contains(errorCode)) m = cm[errorCode];
+- fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++ if (errorCode < 1000) {
++ fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++ } else {
++ QNetworkReply::NetworkError error = (QNetworkReply::NetworkError)(errorCode - 1000);
++ QString errorValue;
++ QMetaObject meta = QNetworkReply::staticMetaObject;
++ for (int i=0; i < meta.enumeratorCount(); ++i) {
++ QMetaEnum m = meta.enumerator(i);
++ if (m.name() == QLatin1String("NetworkError")) {
++ errorValue = QLatin1String(m.valueToKey(error));
++ break;
++ }
++ }
++ fprintf(stderr, "Exit with code %d due to network error: %s\n", c, errorValue.toLocal8Bit().data());
++ }
+ return c;
+ } else if (!success) {
+ fprintf(stderr, "Exit with code %d, due to unknown error.\n", EXIT_FAILURE);
+--
+2.0.0
+