merged AI doc, some new pages
This commit is contained in:
@@ -1,9 +1,41 @@
|
||||
//! \~\ingroup HTTP
|
||||
//! \~\file pihttpconstants.h
|
||||
//! \brief HTTP constants and enumerations
|
||||
//! \~english Definitions for HTTP methods, status codes and header names
|
||||
//! \~russian Определения HTTP методов, кодов состояния и имен заголовков
|
||||
//! \details
|
||||
//! \~english Provides enum classes for HTTP methods and status codes, and a namespace with HTTP header name constants
|
||||
//! \~russian Предоставляет классы перечислений для HTTP методов и кодов состояния, а также пространство имён с константами имён HTTP
|
||||
//! заголовков.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
HTTP constants and enumerations
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef pihttpconstants_h
|
||||
#define pihttpconstants_h
|
||||
|
||||
|
||||
//! \~english Namespace with shared HTTP constants and vocabulary.
|
||||
//! \~russian Пространство имен с общими HTTP-константами и базовой терминологией.
|
||||
namespace PIHTTP {
|
||||
|
||||
//! \~english HTTP request method.
|
||||
//! \~russian HTTP-метод запроса.
|
||||
enum class Method {
|
||||
Unknown,
|
||||
Get,
|
||||
@@ -14,9 +46,11 @@ enum class Method {
|
||||
Connect,
|
||||
Options,
|
||||
Trace,
|
||||
Patch
|
||||
Patch,
|
||||
};
|
||||
|
||||
//! \~english HTTP status code.
|
||||
//! \~russian HTTP-код статуса.
|
||||
enum class Code {
|
||||
Unknown = -1,
|
||||
Continue = 100,
|
||||
@@ -90,7 +124,14 @@ enum class Code {
|
||||
NetworkAuthenticationRequired = 511,
|
||||
};
|
||||
|
||||
//! \~english Namespace with shared HTTP header field name literals.
|
||||
//! \~russian Пространство имен с общими строковыми литералами имен HTTP-заголовков.
|
||||
//!
|
||||
//! \~english Constant names follow the header field names used on the wire.
|
||||
//! \~russian Имена констант повторяют имена полей заголовков, используемые в протоколе.
|
||||
namespace Header {
|
||||
//! \~english Common request and response header fields.
|
||||
//! \~russian Общие поля заголовков запросов и ответов.
|
||||
constexpr static char Accept[] = "Accept";
|
||||
constexpr static char AcceptCharset[] = "Accept-Charset";
|
||||
constexpr static char AcceptEncoding[] = "Accept-Encoding";
|
||||
@@ -140,7 +181,11 @@ constexpr static char UserAgent[] = "User-Agent";
|
||||
constexpr static char Vary[] = "Vary";
|
||||
constexpr static char Via[] = "Via";
|
||||
constexpr static char WWWAuthenticate[] = "WWW-Authenticate";
|
||||
//! \~english Special wildcard token used by some HTTP fields.
|
||||
//! \~russian Специальный подстановочный токен, используемый некоторыми HTTP-полями.
|
||||
constexpr static char Asterisk[] = "*";
|
||||
//! \~english Extended, CORS, security and protocol-specific header fields.
|
||||
//! \~russian Расширенные, CORS-, security- и protocol-specific поля заголовков.
|
||||
constexpr static char AIM[] = "A-IM";
|
||||
constexpr static char AcceptAdditions[] = "Accept-Additions";
|
||||
constexpr static char AcceptCH[] = "Accept-CH";
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
//! \~\file pihttptypes.h
|
||||
//! \~\ingroup HTTP
|
||||
//! \~\brief
|
||||
//! \~english Shared HTTP message container types
|
||||
//! \~russian Общие типы контейнеров HTTP-сообщений
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Shared HTTP message container types
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef pihttptypes_h
|
||||
#define pihttptypes_h
|
||||
|
||||
@@ -6,71 +30,76 @@
|
||||
#include "pistringlist.h"
|
||||
|
||||
|
||||
//! \~english Namespace with shared HTTP data types.
|
||||
//! \~russian Пространство имен с общими HTTP-типами данных.
|
||||
namespace PIHTTP {
|
||||
|
||||
|
||||
//! \~english Immutable HTTP message container with accessors for message components
|
||||
//! \~russian Контейнер для неизменяемого HTTP-сообщения с методами доступа к компонентам
|
||||
//! \~\ingroup HTTP
|
||||
//! \~\brief
|
||||
//! \~english Immutable HTTP message view with accessors for method, path, headers and body.
|
||||
//! \~russian Неизменяемое HTTP-сообщение с доступом к методу, пути, заголовкам и телу.
|
||||
class PIP_EXPORT MessageConst {
|
||||
public:
|
||||
//! \~english Gets the HTTP method used in the message
|
||||
//! \~russian Возвращает HTTP-метод, использованный в сообщении
|
||||
//! \~english Returns the HTTP method of the message.
|
||||
//! \~russian Возвращает HTTP-метод сообщения.
|
||||
PIHTTP::Method method() const { return m_method; }
|
||||
|
||||
//! \~english Gets the HTTP status code
|
||||
//! \~russian Возвращает HTTP-статус код
|
||||
//! \~english Returns the HTTP status code of the message.
|
||||
//! \~russian Возвращает HTTP-код статуса сообщения.
|
||||
PIHTTP::Code code() const { return m_code; }
|
||||
|
||||
//! \~english Checks if status code is informational (1xx)
|
||||
//! \~russian Проверяет, является ли статус код информационным (1xx)
|
||||
//! \~english Returns \c true for informational status codes in the 1xx range.
|
||||
//! \~russian Возвращает \c true для информационных кодов статуса из диапазона 1xx.
|
||||
bool isCodeInformational() const;
|
||||
|
||||
//! \~english Checks if status code indicates success (2xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на успех (2xx)
|
||||
//! \~english Returns \c true for successful status codes in the 2xx range.
|
||||
//! \~russian Возвращает \c true для успешных кодов статуса из диапазона 2xx.
|
||||
bool isCodeSuccess() const;
|
||||
|
||||
//! \~english Checks if status code indicates redirection (3xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на перенаправление (3xx)
|
||||
//! \~english Returns \c true for redirection status codes in the 3xx range.
|
||||
//! \~russian Возвращает \c true для кодов перенаправления из диапазона 3xx.
|
||||
bool isCodeRedirection() const;
|
||||
|
||||
//! \~english Checks if status code indicates client error (4xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на ошибку клиента (4xx)
|
||||
//! \~english Returns \c true for client error status codes in the 4xx range.
|
||||
//! \~russian Возвращает \c true для кодов ошибки клиента из диапазона 4xx.
|
||||
bool isCodeClientError() const;
|
||||
|
||||
//! \~english Checks if status code indicates server error (5xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на ошибку сервера (5xx)
|
||||
//! \~english Returns \c true for server error status codes in the 5xx range.
|
||||
//! \~russian Возвращает \c true для кодов ошибки сервера из диапазона 5xx.
|
||||
bool isCodeServerError() const;
|
||||
|
||||
//! \~english Checks if status code indicates any error (4xx or 5xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на любую ошибку (4xx или 5xx)
|
||||
//! \~english Returns \c true for any client or server error status code.
|
||||
//! \~russian Возвращает \c true для любого кода ошибки клиента или сервера.
|
||||
bool isCodeError() const { return isCodeClientError() || isCodeServerError(); }
|
||||
|
||||
//! \~english Gets the request/response path
|
||||
//! \~russian Возвращает путь запроса/ответа
|
||||
|
||||
//! \~english Returns the request path or response target path.
|
||||
//! \~russian Возвращает путь запроса или целевой путь ответа.
|
||||
const PIString & path() const { return m_path; }
|
||||
|
||||
//! \~english Gets path components as list
|
||||
//! \~russian Возвращает компоненты пути в виде списка
|
||||
//! \~english Returns the path split into non-empty components.
|
||||
//! \~russian Возвращает путь, разбитый на непустые компоненты.
|
||||
PIStringList pathList() const { return m_path.split('/').removeAll({}); }
|
||||
|
||||
//! \~english Gets the message body
|
||||
//! \~russian Возвращает тело сообщения
|
||||
//! \~english Returns the message body.
|
||||
//! \~russian Возвращает тело сообщения.
|
||||
const PIByteArray & body() const { return m_body; }
|
||||
|
||||
//! \~english Gets all message headers
|
||||
//! \~russian Возвращает все заголовки сообщения
|
||||
//! \~english Returns all message headers.
|
||||
//! \~russian Возвращает все заголовки сообщения.
|
||||
const PIMap<PIString, PIString> & headers() const { return m_headers; }
|
||||
|
||||
//! \~english Gets URL query arguments
|
||||
//! \~russian Возвращает URL query аргументы
|
||||
//! \~english Returns parsed query arguments from the URL.
|
||||
//! \~russian Возвращает разобранные query-аргументы URL.
|
||||
const PIMap<PIString, PIString> & queryArguments() const { return m_query_arguments; }
|
||||
|
||||
//! \~english Gets URL path arguments
|
||||
//! \~russian Возвращает URL path аргументы
|
||||
//! \~english Returns extracted path arguments.
|
||||
//! \~russian Возвращает извлеченные аргументы пути.
|
||||
const PIMap<PIString, PIString> & pathArguments() const { return m_path_arguments; }
|
||||
|
||||
//! \~english Gets all message arguments (query + path)
|
||||
//! \~russian Возвращает все аргументы сообщения (query + path)
|
||||
//! \~english Returns the combined argument map from query and path arguments.
|
||||
//! \~russian Возвращает объединенную карту аргументов из query и path.
|
||||
const PIMap<PIString, PIString> & arguments() const { return m_arguments; }
|
||||
|
||||
protected:
|
||||
@@ -83,78 +112,101 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Mutable HTTP message container with modifiers for message components
|
||||
//! \~russian Контейнер для изменяемого HTTP-сообщения с методами модификации
|
||||
//! \~\ingroup HTTP
|
||||
//! \~\brief
|
||||
//! \~english Mutable HTTP message with setters and argument/header modifiers.
|
||||
//! \~russian Изменяемое HTTP-сообщение с сеттерами и методами изменения аргументов и заголовков.
|
||||
class PIP_EXPORT MessageMutable: public MessageConst {
|
||||
public:
|
||||
//! \~english Sets the HTTP method
|
||||
//! \~russian Устанавливает HTTP-метод
|
||||
//! \~english Sets the HTTP method.
|
||||
//! \~russian Устанавливает HTTP-метод.
|
||||
MessageMutable & setMethod(PIHTTP::Method m);
|
||||
|
||||
//! \~english Sets the HTTP status code
|
||||
//! \~russian Устанавливает HTTP-статус код
|
||||
//! \~english Sets the HTTP status code.
|
||||
//! \~russian Устанавливает HTTP-код статуса.
|
||||
MessageMutable & setCode(PIHTTP::Code c);
|
||||
|
||||
//! \~english Sets the request/response path
|
||||
//! \~russian Устанавливает путь запроса/ответа
|
||||
//! \~english Sets the request path or response target path.
|
||||
//! \~russian Устанавливает путь запроса или целевой путь ответа.
|
||||
MessageMutable & setPath(PIString p);
|
||||
|
||||
//! \~english Sets the message body
|
||||
//! \~russian Устанавливает тело сообщения
|
||||
//! \~english Sets the message body.
|
||||
//! \~russian Устанавливает тело сообщения.
|
||||
MessageMutable & setBody(PIByteArray b);
|
||||
|
||||
|
||||
//! \~english Returns all message headers.
|
||||
//! \~russian Возвращает все заголовки сообщения.
|
||||
const PIMap<PIString, PIString> & headers() const { return m_headers; }
|
||||
|
||||
//! \~english Returns a modifiable map of all arguments.
|
||||
//! \~russian Возвращает изменяемую карту всех аргументов.
|
||||
PIMap<PIString, PIString> & arguments() { return m_arguments; }
|
||||
|
||||
//! \~english Returns all arguments.
|
||||
//! \~russian Возвращает все аргументы.
|
||||
const PIMap<PIString, PIString> & arguments() const { return m_arguments; }
|
||||
|
||||
//! \~english Returns query arguments.
|
||||
//! \~russian Возвращает query-аргументы.
|
||||
const PIMap<PIString, PIString> & queryArguments() const { return m_query_arguments; }
|
||||
|
||||
//! \~english Returns path arguments.
|
||||
//! \~russian Возвращает аргументы пути.
|
||||
const PIMap<PIString, PIString> & pathArguments() const { return m_path_arguments; }
|
||||
|
||||
|
||||
//! \~english Returns a modifiable map of all message headers.
|
||||
//! \~russian Возвращает изменяемую карту всех заголовков сообщения.
|
||||
PIMap<PIString, PIString> & headers() { return m_headers; }
|
||||
|
||||
//! \~english Adds a header to the message
|
||||
//! \~russian Добавляет заголовок к сообщению
|
||||
//! \~english Adds or replaces a header in the message.
|
||||
//! \~russian Добавляет заголовок в сообщение или заменяет существующий.
|
||||
MessageMutable & addHeader(const PIString & header, const PIString & value);
|
||||
|
||||
//! \~english Removes a header from the message
|
||||
//! \~russian Удаляет заголовок из сообщения
|
||||
//! \~english Removes a header from the message.
|
||||
//! \~russian Удаляет заголовок из сообщения.
|
||||
MessageMutable & removeHeader(const PIString & header);
|
||||
|
||||
//! \~english Gets reference to URL query arguments
|
||||
//! \~russian Возвращает ссылку на URL query аргументы
|
||||
|
||||
//! \~english Returns a modifiable map of query arguments.
|
||||
//! \~russian Возвращает изменяемую карту query-аргументов.
|
||||
PIMap<PIString, PIString> & queryArguments() { return m_query_arguments; }
|
||||
|
||||
//! \~english Adds an URL query argument to the message
|
||||
//! \~russian Добавляет URL query аргумент к сообщению
|
||||
//! \~english Adds or replaces a query argument.
|
||||
//! \~russian Добавляет query-аргумент или заменяет существующий.
|
||||
MessageMutable & addQueryArgument(const PIString & arg, const PIString & value);
|
||||
|
||||
//! \~english Removes an URL query argument from the message
|
||||
//! \~russian Удаляет URL query аргумент из сообщения
|
||||
//! \~english Removes a query argument.
|
||||
//! \~russian Удаляет query-аргумент.
|
||||
MessageMutable & removeQueryArgument(const PIString & arg);
|
||||
|
||||
//! \~english Gets reference to URL path arguments
|
||||
//! \~russian Возвращает ссылку на URL path аргументы
|
||||
|
||||
//! \~english Returns a modifiable map of path arguments.
|
||||
//! \~russian Возвращает изменяемую карту аргументов пути.
|
||||
PIMap<PIString, PIString> & pathArguments() { return m_path_arguments; }
|
||||
|
||||
//! \~english Adds an URL path argument to the message
|
||||
//! \~russian Добавляет URL path аргумент к сообщению
|
||||
//! \~english Adds or replaces a path argument.
|
||||
//! \~russian Добавляет аргумент пути или заменяет существующий.
|
||||
MessageMutable & addPathArgument(const PIString & arg, const PIString & value);
|
||||
|
||||
//! \~english Removes an URL path argument from the message
|
||||
//! \~russian Удаляет URL query path из сообщения
|
||||
//! \~english Removes a path argument.
|
||||
//! \~russian Удаляет аргумент пути.
|
||||
MessageMutable & removePathArgument(const PIString & arg);
|
||||
|
||||
//! \~english Creates message from HTTP status code
|
||||
//! \~russian Создает сообщение из HTTP-статус кода
|
||||
|
||||
//! \~english Creates a message initialized from an HTTP status code.
|
||||
//! \~russian Создает сообщение, инициализированное HTTP-кодом статуса.
|
||||
static MessageMutable fromCode(PIHTTP::Code c);
|
||||
|
||||
//! \~english Creates message from HTTP method
|
||||
//! \~russian Создает сообщение из HTTP-метода
|
||||
//! \~english Creates a message initialized from an HTTP method.
|
||||
//! \~russian Создает сообщение, инициализированное HTTP-методом.
|
||||
static MessageMutable fromMethod(PIHTTP::Method m);
|
||||
};
|
||||
|
||||
|
||||
//! \~english Gets string representation of HTTP method
|
||||
//! \~russian Возвращает строковое представление HTTP-метода
|
||||
//! \~english Returns the canonical string representation of an HTTP method.
|
||||
//! \~russian Возвращает каноническое строковое представление HTTP-метода.
|
||||
PIP_EXPORT const char * methodName(Method m);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user