|
| 1 | +From f2eec1201ecd8922535717e3db33e2ffc2bebc13 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Dirk Vanden Boer <dirk.vdb@gmail.com> |
| 3 | +Date: Sun, 5 Oct 2025 13:56:39 +0200 |
| 4 | +Subject: [PATCH] Qt6 causes HTTP/2 errors |
| 5 | + |
| 6 | +https://github.com/maplibre/maplibre-native/issues/3644 |
| 7 | +--- |
| 8 | + platform/qt/src/mbgl/http_file_source.cpp | 35 ++++++++++++++++++----- |
| 9 | + 1 file changed, 28 insertions(+), 7 deletions(-) |
| 10 | + |
| 11 | +diff --git a/platform/qt/src/mbgl/http_file_source.cpp b/platform/qt/src/mbgl/http_file_source.cpp |
| 12 | +index 43df2470715f..dd3bff2c1fdc 100644 |
| 13 | +--- a/platform/qt/src/mbgl/http_file_source.cpp |
| 14 | ++++ b/platform/qt/src/mbgl/http_file_source.cpp |
| 15 | +@@ -68,12 +68,21 @@ void HTTPFileSource::Impl::cancel(HTTPRequest* req) { |
| 16 | + |
| 17 | + if (requestsVector.empty()) { |
| 18 | + m_pending.erase(it); |
| 19 | ++#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 4) |
| 20 | ++ // Qt 5.9.4 introduced HTTP/2, in the ideal world we would like to know if this reply |
| 21 | ++ // is from a HTTP/2 connection. At this point in time we cannot check it. If HTTP/2 is |
| 22 | ++ // in use we may not abort the connection. |
| 23 | ++ Q_UNUSED(reply); |
| 24 | ++#else |
| 25 | ++ // Works fine with HTTP/1 |
| 26 | + if (reply) reply->abort(); |
| 27 | ++#endif |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + void HTTPFileSource::Impl::onReplyFinished() { |
| 32 | + QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); |
| 33 | ++ if (!reply) return; |
| 34 | + const QUrl& url = reply->request().url(); |
| 35 | + |
| 36 | + auto it = m_pending.find(url); |
| 37 | +@@ -82,14 +91,26 @@ void HTTPFileSource::Impl::onReplyFinished() { |
| 38 | + return; |
| 39 | + } |
| 40 | + |
| 41 | +- QByteArray data = reply->readAll(); |
| 42 | +- QVector<HTTPRequest*>& requestsVector = it.value().second; |
| 43 | ++ // Error handling |
| 44 | ++ if (reply->error() != QNetworkReply::NoError) { |
| 45 | ++ qWarning() << "Network error for URL" << url << ":" << reply->errorString(); |
| 46 | ++ |
| 47 | ++ QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); |
| 48 | ++ if (!statusCode.isValid()) { |
| 49 | ++ qWarning() << "No HTTP status code received; possible connection/protocol failure."; |
| 50 | ++ } |
| 51 | ++ |
| 52 | ++ m_manager->clearConnectionCache(); |
| 53 | ++ } else { |
| 54 | ++ QByteArray data = reply->readAll(); |
| 55 | ++ QVector<HTTPRequest*>& requestsVector = it.value().second; |
| 56 | + |
| 57 | +- // Cannot use the iterator to walk the requestsVector |
| 58 | +- // because calling handleNetworkReply() might get |
| 59 | +- // requests added to the requestsVector. |
| 60 | +- while (!requestsVector.isEmpty()) { |
| 61 | +- requestsVector.takeFirst()->handleNetworkReply(reply, data); |
| 62 | ++ // Cannot use the iterator to walk the requestsVector |
| 63 | ++ // because calling handleNetworkReply() might get |
| 64 | ++ // requests added to the requestsVector. |
| 65 | ++ while (!requestsVector.isEmpty()) { |
| 66 | ++ requestsVector.takeFirst()->handleNetworkReply(reply, data); |
| 67 | ++ } |
| 68 | + } |
| 69 | + |
| 70 | + m_pending.erase(it); |
0 commit comments