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.
32 #include <QHostAddress>
38 inline const char METHOD_GET
[] = "GET";
39 inline const char METHOD_POST
[] = "POST";
41 inline const char HEADER_CACHE_CONTROL
[] = "cache-control";
42 inline const char HEADER_CONNECTION
[] = "connection";
43 inline const char HEADER_CONTENT_DISPOSITION
[] = "content-disposition";
44 inline const char HEADER_CONTENT_ENCODING
[] = "content-encoding";
45 inline const char HEADER_CONTENT_LENGTH
[] = "content-length";
46 inline const char HEADER_CONTENT_SECURITY_POLICY
[] = "content-security-policy";
47 inline const char HEADER_CONTENT_TYPE
[] = "content-type";
48 inline const char HEADER_DATE
[] = "date";
49 inline const char HEADER_HOST
[] = "host";
50 inline const char HEADER_ORIGIN
[] = "origin";
51 inline const char HEADER_REFERER
[] = "referer";
52 inline const char HEADER_REFERRER_POLICY
[] = "referrer-policy";
53 inline const char HEADER_SET_COOKIE
[] = "set-cookie";
54 inline const char HEADER_X_CONTENT_TYPE_OPTIONS
[] = "x-content-type-options";
55 inline const char HEADER_X_FORWARDED_FOR
[] = "x-forwarded-for";
56 inline const char HEADER_X_FORWARDED_HOST
[] = "x-forwarded-host";
57 inline const char HEADER_X_FRAME_OPTIONS
[] = "x-frame-options";
58 inline const char HEADER_X_XSS_PROTECTION
[] = "x-xss-protection";
60 inline const char HEADER_REQUEST_METHOD_GET
[] = "GET";
61 inline const char HEADER_REQUEST_METHOD_HEAD
[] = "HEAD";
62 inline const char HEADER_REQUEST_METHOD_POST
[] = "POST";
64 inline const char CONTENT_TYPE_HTML
[] = "text/html";
65 inline const char CONTENT_TYPE_CSS
[] = "text/css";
66 inline const char CONTENT_TYPE_TXT
[] = "text/plain; charset=UTF-8";
67 inline const char CONTENT_TYPE_JS
[] = "application/javascript";
68 inline const char CONTENT_TYPE_JSON
[] = "application/json";
69 inline const char CONTENT_TYPE_GIF
[] = "image/gif";
70 inline const char CONTENT_TYPE_PNG
[] = "image/png";
71 inline const char CONTENT_TYPE_FORM_ENCODED
[] = "application/x-www-form-urlencoded";
72 inline const char CONTENT_TYPE_FORM_DATA
[] = "multipart/form-data";
74 // portability: "\r\n" doesn't guarantee mapping to the correct symbol
75 inline const char CRLF
[] = {0x0D, 0x0A, '\0'};
79 QHostAddress localAddress
;
82 QHostAddress clientAddress
;
89 QString type
; // MIME type
99 using HeaderMap
= QMap
<QString
, QString
>; // <Header name, Header value>
107 QHash
<QString
, QByteArray
> query
;
108 QHash
<QString
, QString
> posts
;
109 QVector
<UploadedFile
> files
;
112 struct ResponseStatus
120 ResponseStatus status
;
124 Response(uint code
= 200, const QString
&text
= QLatin1String("OK"))
125 : status
{code
, text
}