Add a function in NetworkCommon parseHeaderList which parses a header list as a string into a vector of header pairs (#2623)

This commit is contained in:
pajlada
2021-04-17 13:49:19 +02:00
committed by GitHub
parent cceadf473a
commit 2f906c5504
9 changed files with 119 additions and 11 deletions
+12
View File
@@ -1,6 +1,9 @@
#pragma once
#include <functional>
#include <vector>
#include <QString>
class QNetworkReply;
@@ -22,4 +25,13 @@ enum class NetworkRequestType {
Patch,
};
// parseHeaderList takes a list of headers in string form,
// where each header pair is separated by semicolons (;) and the header name and value is divided by a colon (:)
//
// We return a vector of pairs, where the first value is the header name and the second value is the header value
//
// e.g. "Authorization:secretkey;NextHeader:boo" will return [{"Authorization", "secretkey"}, {"NextHeader", "boo"}]
std::vector<std::pair<QByteArray, QByteArray>> parseHeaderList(
const QString &headerListString);
} // namespace chatterino