mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 00:14:57 +00:00
Define and use Http::HeaderMap type
This commit is contained in:
parent
d57b9be706
commit
be152f45c9
@ -57,7 +57,7 @@ namespace
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parseHeaderLine(const QString &line, QStringMap &out)
|
bool parseHeaderLine(const QString &line, HeaderMap &out)
|
||||||
{
|
{
|
||||||
// [rfc7230] 3.2. Header Fields
|
// [rfc7230] 3.2. Header Fields
|
||||||
const int i = line.indexOf(':');
|
const int i = line.indexOf(':');
|
||||||
@ -287,7 +287,7 @@ bool RequestParser::parseFormData(const QByteArray &data)
|
|||||||
const QString headers = QString::fromLatin1(list[0]);
|
const QString headers = QString::fromLatin1(list[0]);
|
||||||
const QByteArray payload = viewWithoutEndingWith(list[1], CRLF);
|
const QByteArray payload = viewWithoutEndingWith(list[1], CRLF);
|
||||||
|
|
||||||
QStringMap headersMap;
|
HeaderMap headersMap;
|
||||||
const QVector<QStringRef> headerLines = headers.splitRef(CRLF, QString::SkipEmptyParts);
|
const QVector<QStringRef> headerLines = headers.splitRef(CRLF, QString::SkipEmptyParts);
|
||||||
for (const auto &line : headerLines) {
|
for (const auto &line : headerLines) {
|
||||||
if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive)) {
|
if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive)) {
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include "base/types.h"
|
|
||||||
|
|
||||||
namespace Http
|
namespace Http
|
||||||
{
|
{
|
||||||
const char METHOD_GET[] = "GET";
|
const char METHOD_GET[] = "GET";
|
||||||
@ -98,12 +96,14 @@ namespace Http
|
|||||||
QString value;
|
QString value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using HeaderMap = QMap<QString, QString>; // <Header name, Header value>
|
||||||
|
|
||||||
struct Request
|
struct Request
|
||||||
{
|
{
|
||||||
QString version;
|
QString version;
|
||||||
QString method;
|
QString method;
|
||||||
QString path;
|
QString path;
|
||||||
QStringMap headers;
|
HeaderMap headers;
|
||||||
QHash<QString, QByteArray> query;
|
QHash<QString, QByteArray> query;
|
||||||
QHash<QString, QString> posts;
|
QHash<QString, QString> posts;
|
||||||
QVector<UploadedFile> files;
|
QVector<UploadedFile> files;
|
||||||
@ -118,7 +118,7 @@ namespace Http
|
|||||||
struct Response
|
struct Response
|
||||||
{
|
{
|
||||||
ResponseStatus status;
|
ResponseStatus status;
|
||||||
QStringMap headers;
|
HeaderMap headers;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
|
|
||||||
Response(uint code = 200, const QString &text = "OK")
|
Response(uint code = 200, const QString &text = "OK")
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "base/http/httperror.h"
|
#include "base/http/httperror.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
|
#include "base/types.h"
|
||||||
#include "base/utils/bytearray.h"
|
#include "base/utils/bytearray.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user