Fix tab order in RSS widget
[qBittorrent.git] / src / base / http / types.h
blobdcc8397449b409add624d540bc70add20d8d65b8
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2018 Mike Tzou (Chocobo1)
4 * Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
30 #pragma once
32 #include <QByteArray>
33 #include <QHostAddress>
34 #include <QList>
35 #include <QString>
37 #include "base/global.h"
39 namespace Http
41 inline const QString METHOD_GET = u"GET"_s;
42 inline const QString METHOD_POST = u"POST"_s;
44 inline const QString HEADER_CACHE_CONTROL = u"cache-control"_s;
45 inline const QString HEADER_CONNECTION = u"connection"_s;
46 inline const QString HEADER_CONTENT_DISPOSITION = u"content-disposition"_s;
47 inline const QString HEADER_CONTENT_ENCODING = u"content-encoding"_s;
48 inline const QString HEADER_CONTENT_LENGTH = u"content-length"_s;
49 inline const QString HEADER_CONTENT_SECURITY_POLICY = u"content-security-policy"_s;
50 inline const QString HEADER_CONTENT_TYPE = u"content-type"_s;
51 inline const QString HEADER_CROSS_ORIGIN_OPENER_POLICY = u"cross-origin-opener-policy"_s;
52 inline const QString HEADER_DATE = u"date"_s;
53 inline const QString HEADER_HOST = u"host"_s;
54 inline const QString HEADER_ORIGIN = u"origin"_s;
55 inline const QString HEADER_REFERER = u"referer"_s;
56 inline const QString HEADER_REFERRER_POLICY = u"referrer-policy"_s;
57 inline const QString HEADER_SET_COOKIE = u"set-cookie"_s;
58 inline const QString HEADER_X_CONTENT_TYPE_OPTIONS = u"x-content-type-options"_s;
59 inline const QString HEADER_X_FORWARDED_FOR = u"x-forwarded-for"_s;
60 inline const QString HEADER_X_FORWARDED_HOST = u"x-forwarded-host"_s;
61 inline const QString HEADER_X_FORWARDED_PROTO = u"X-forwarded-proto"_s;
62 inline const QString HEADER_X_FRAME_OPTIONS = u"x-frame-options"_s;
63 inline const QString HEADER_X_XSS_PROTECTION = u"x-xss-protection"_s;
65 inline const QString HEADER_REQUEST_METHOD_GET = u"GET"_s;
66 inline const QString HEADER_REQUEST_METHOD_HEAD = u"HEAD"_s;
67 inline const QString HEADER_REQUEST_METHOD_POST = u"POST"_s;
69 inline const QString CONTENT_TYPE_HTML = u"text/html"_s;
70 inline const QString CONTENT_TYPE_CSS = u"text/css"_s;
71 inline const QString CONTENT_TYPE_TXT = u"text/plain; charset=UTF-8"_s;
72 inline const QString CONTENT_TYPE_JS = u"application/javascript"_s;
73 inline const QString CONTENT_TYPE_JSON = u"application/json"_s;
74 inline const QString CONTENT_TYPE_GIF = u"image/gif"_s;
75 inline const QString CONTENT_TYPE_PNG = u"image/png"_s;
76 inline const QString CONTENT_TYPE_FORM_ENCODED = u"application/x-www-form-urlencoded"_s;
77 inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_s;
79 // portability: "\r\n" doesn't guarantee mapping to the correct symbol
80 inline const QByteArray CRLF = QByteArrayLiteral("\x0D\x0A");
82 struct Environment
84 QHostAddress localAddress;
85 quint16 localPort = 0;
87 QHostAddress clientAddress;
88 quint16 clientPort = 0;
91 struct UploadedFile
93 QString filename;
94 QString type; // MIME type
95 QByteArray data;
98 struct Header
100 QString name;
101 QString value;
104 using HeaderMap = QMap<QString, QString>; // <Header name, Header value>
106 struct Request
108 QString version;
109 QString method;
110 QString path;
111 HeaderMap headers;
112 QHash<QString, QByteArray> query;
113 QHash<QString, QString> posts;
114 QList<UploadedFile> files;
117 struct ResponseStatus
119 uint code;
120 QString text;
123 struct Response
125 ResponseStatus status;
126 HeaderMap headers;
127 QByteArray content;
129 Response(uint code = 200, const QString &text = u"OK"_s)
130 : status {code, text}