Improve parsing of HTTP headers

Parse HTTP headers using raw byte arrays instead of strings. This allows us to apply different encodings for different parts.
This change is backward compatible and should not affect any existing operation, so WebAPI version bump is not required.

PR #23083.
This commit is contained in:
Hanabishi
2025-08-22 23:51:51 +05:00
committed by GitHub
parent feacfb0627
commit bda37cbade
5 changed files with 77 additions and 27 deletions

View File

@@ -31,7 +31,6 @@
#include <QByteArray>
#include <QByteArrayMatcher>
#include <QByteArrayView>
#include <QList>
QList<QByteArrayView> Utils::ByteArray::splitToViews(const QByteArrayView in, const QByteArrayView sep, const Qt::SplitBehavior behavior)

View File

@@ -31,9 +31,9 @@
#include <Qt>
#include <QtContainerFwd>
#include <QByteArrayView>
class QByteArray;
class QByteArrayView;
namespace Utils::ByteArray
{
@@ -42,4 +42,19 @@ namespace Utils::ByteArray
QByteArray asQByteArray(QByteArrayView view);
QByteArray toBase32(const QByteArray &in);
template <typename T>
T unquote(const T &arr, const QByteArrayView quotes = "\"")
{
if (arr.length() < 2)
return arr;
for (const char quote : quotes)
{
if (arr.startsWith(quote) && arr.endsWith(quote))
return arr.sliced(1, (arr.length() - 2));
}
return arr;
}
}