mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 00:47:21 -06:00
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:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user