qBittorrent/src/base/http/requestparser.h

75 lines
2.5 KiB
C
Raw Normal View History

2008-05-17 17:22:54 +04:00
/*
2014-08-22 22:07:19 +04:00
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2018 Mike Tzou (Chocobo1)
2014-08-22 22:07:19 +04:00
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
2008-05-17 17:22:54 +04:00
*
2009-04-05 22:48:45 +04:00
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
2008-05-17 17:22:54 +04:00
*
2009-04-05 22:48:45 +04:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2008-05-17 17:22:54 +04:00
*
2009-04-05 22:48:45 +04:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
2008-05-17 17:22:54 +04:00
*/
#ifndef HTTP_REQUESTPARSER_H
#define HTTP_REQUESTPARSER_H
2008-05-17 17:22:54 +04:00
#include "types.h"
2008-05-17 17:22:54 +04:00
namespace Http
{
2015-05-13 18:39:48 +03:00
class RequestParser
{
2015-05-13 18:39:48 +03:00
public:
enum class ParseStatus
2015-05-13 18:39:48 +03:00
{
OK,
Incomplete,
2015-05-13 18:39:48 +03:00
BadRequest
};
2014-08-22 22:07:19 +04:00
struct ParseResult
{
// when `status != ParseStatus::OK`, `request` & `frameSize` are undefined
ParseStatus status;
Request request;
long frameSize; // http request frame size (bytes)
};
static ParseResult parse(const QByteArray &data);
static const long MAX_CONTENT_SIZE = 64 * 1024 * 1024; // 64 MB
2011-09-25 12:18:41 +04:00
2015-05-13 18:39:48 +03:00
private:
RequestParser();
2014-08-22 22:07:19 +04:00
ParseResult doParse(const QByteArray &data);
bool parseStartLines(const QString &data);
bool parseRequestLine(const QString &line);
2014-08-22 22:07:19 +04:00
bool parsePostMessage(const QByteArray &data);
2015-05-13 18:39:48 +03:00
bool parseFormData(const QByteArray &data);
2008-05-17 17:22:54 +04:00
2015-05-13 18:39:48 +03:00
Request m_request;
};
}
#endif // HTTP_REQUESTPARSER_H