# Http.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/web/protocol/http/Http.hpp"

# Headers

Namespace: oatpp::web::protocol::http

Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

typedef oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> Headers

# QueryParams

Namespace: oatpp::web::protocol::http

Typedef for query parameters map. For more info see oatpp::data::share::LazyStringMap.

typedef oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabel> QueryParams

# Status

Http status.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class Status {}
}}}}

# Fields

Type Name Summary
const Status CODE_100 Continue.
const Status CODE_101 Switching Protocols.
const Status CODE_102 Processing.
const Status CODE_200 OK.
const Status CODE_201 Created.
const Status CODE_202 Accepted.
const Status CODE_203 Non-Authoritative Information.
const Status CODE_204 No Content.
const Status CODE_205 Reset Content.
const Status CODE_206 Partial Content.
const Status CODE_207 Multi-Status.
const Status CODE_226 IM Used.
const Status CODE_300 Multiple Choices.
const Status CODE_301 Moved Permanently.
const Status CODE_302 Moved Temporarily.
const Status CODE_303 See Other.
const Status CODE_304 Not Modified.
const Status CODE_305 Use Proxy.
const Status CODE_306 Reserved.
const Status CODE_307 Temporary Redirect.
const Status CODE_400 Bad Request.
const Status CODE_401 Unauthorized.
const Status CODE_402 Payment Required.
const Status CODE_403 Forbidden.
const Status CODE_404 Not Found.
const Status CODE_405 Method Not Allowed.
const Status CODE_406 Not Acceptable.
const Status CODE_407 Proxy Authentication Required.
const Status CODE_408 Request Timeout.
const Status CODE_409 Conflict.
const Status CODE_410 Gone
const Status CODE_411 Length Required.
const Status CODE_412 Precondition Failed.
const Status CODE_413 Request Entity Too Large.
const Status CODE_414 Request-URI Too Large.
const Status CODE_415 Unsupported Media Type.
const Status CODE_416 Requested Range Not Satisfiable.
const Status CODE_417 Expectation Failed.
const Status CODE_422 Unprocessable Entity.
const Status CODE_423 Locked.
const Status CODE_424 Failed Dependency.
const Status CODE_425 Unordered Collection.
const Status CODE_426 Upgrade Required.
const Status CODE_428 Precondition Required.
const Status CODE_429 Too Many Requests.
const Status CODE_431 Request Header Fields Too Large.
const Status CODE_434 Requested host unavailable.
const Status CODE_444 Close connection withot sending headers.
const Status CODE_449 Retry With.
const Status CODE_451 Unavailable For Legal Reasons.
const Status CODE_500 Internal Server Error.
const Status CODE_501 Not Implemented.
const Status CODE_502 Bad Gateway.
const Status CODE_503 Service Unavailable.
const Status CODE_504 Gateway Timeout.
const Status CODE_505 HTTP Version Not Supported.
const Status CODE_506 Variant Also Negotiates.
const Status CODE_507 Insufficient Storage.
const Status CODE_508 Loop Detected.
const Status CODE_509 Bandwidth Limit Exceeded.
const Status CODE_510 Not Extended.
const Status CODE_511 Network Authentication Required.
v_int32 code Status code.
const char* description Description.

# Methods

Return Type Name Summary
[none] Status Multiple implementations:
  1. Constructor.
  2. Constructor.

# Status::CODE_100

Continue.

static const Status CODE_100

# Status::CODE_101

Switching Protocols.

static const Status CODE_101

# Status::CODE_102

Processing.

static const Status CODE_102

# Status::CODE_200

OK.

static const Status CODE_200

# Status::CODE_201

Created.

static const Status CODE_201

# Status::CODE_202

Accepted.

static const Status CODE_202

# Status::CODE_203

Non-Authoritative Information.

static const Status CODE_203

# Status::CODE_204

No Content.

static const Status CODE_204

# Status::CODE_205

Reset Content.

static const Status CODE_205

# Status::CODE_206

Partial Content.

static const Status CODE_206

# Status::CODE_207

Multi-Status.

static const Status CODE_207

# Status::CODE_226

IM Used.

static const Status CODE_226

# Status::CODE_300

Multiple Choices.

static const Status CODE_300

# Status::CODE_301

Moved Permanently.

static const Status CODE_301

# Status::CODE_302

Moved Temporarily.

static const Status CODE_302

# Status::CODE_303

See Other.

static const Status CODE_303

# Status::CODE_304

Not Modified.

static const Status CODE_304

# Status::CODE_305

Use Proxy.

static const Status CODE_305

# Status::CODE_306

Reserved.

static const Status CODE_306

# Status::CODE_307

Temporary Redirect.

static const Status CODE_307

# Status::CODE_400

Bad Request.

static const Status CODE_400

# Status::CODE_401

Unauthorized.

static const Status CODE_401

# Status::CODE_402

Payment Required.

static const Status CODE_402

# Status::CODE_403

Forbidden.

static const Status CODE_403

# Status::CODE_404

Not Found.

static const Status CODE_404

# Status::CODE_405

Method Not Allowed.

static const Status CODE_405

# Status::CODE_406

Not Acceptable.

static const Status CODE_406

# Status::CODE_407

Proxy Authentication Required.

static const Status CODE_407

# Status::CODE_408

Request Timeout.

static const Status CODE_408

# Status::CODE_409

Conflict.

static const Status CODE_409

# Status::CODE_410

Gone

static const Status CODE_410

# Status::CODE_411

Length Required.

static const Status CODE_411

# Status::CODE_412

Precondition Failed.

static const Status CODE_412

# Status::CODE_413

Request Entity Too Large.

static const Status CODE_413

# Status::CODE_414

Request-URI Too Large.

static const Status CODE_414

# Status::CODE_415

Unsupported Media Type.

static const Status CODE_415

# Status::CODE_416

Requested Range Not Satisfiable.

static const Status CODE_416

# Status::CODE_417

Expectation Failed.

static const Status CODE_417

# Status::CODE_422

Unprocessable Entity.

static const Status CODE_422

# Status::CODE_423

Locked.

static const Status CODE_423

# Status::CODE_424

Failed Dependency.

static const Status CODE_424

# Status::CODE_425

Unordered Collection.

static const Status CODE_425

# Status::CODE_426

Upgrade Required.

static const Status CODE_426

# Status::CODE_428

Precondition Required.

static const Status CODE_428

# Status::CODE_429

Too Many Requests.

static const Status CODE_429

# Status::CODE_431

Request Header Fields Too Large.

static const Status CODE_431

# Status::CODE_434

Requested host unavailable.

static const Status CODE_434

# Status::CODE_444

Close connection withot sending headers.

static const Status CODE_444

# Status::CODE_449

Retry With.

static const Status CODE_449

# Status::CODE_451

Unavailable For Legal Reasons.

static const Status CODE_451

# Status::CODE_500

Internal Server Error.

static const Status CODE_500

# Status::CODE_501

Not Implemented.

static const Status CODE_501

# Status::CODE_502

Bad Gateway.

static const Status CODE_502

# Status::CODE_503

Service Unavailable.

static const Status CODE_503

# Status::CODE_504

Gateway Timeout.

static const Status CODE_504

# Status::CODE_505

HTTP Version Not Supported.

static const Status CODE_505

# Status::CODE_506

Variant Also Negotiates.

static const Status CODE_506

# Status::CODE_507

Insufficient Storage.

static const Status CODE_507

# Status::CODE_508

Loop Detected.

static const Status CODE_508

# Status::CODE_509

Bandwidth Limit Exceeded.

static const Status CODE_509

# Status::CODE_510

Not Extended.

static const Status CODE_510

# Status::CODE_511

Network Authentication Required.

static const Status CODE_511

# Status::code

Status code.

v_int32 code

# Status::description

Description.

const char* description

# Status::Status

  1. Constructor.
    Status()
      : code(0)
      , description(nullptr)
    
  2. Constructor.
    • @param pCode - status code.
    • @param pDesc - description.
    Status(v_int32 pCode, const char* pDesc)
      : code(pCode)
      , description(pDesc)
    

# HttpError

HttpError extends oatpp::web::protocol::ProtocolError<Status>.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class HttpError : public protocol::ProtocolError<Status> {}
}}}}

# Methods

Return Type Name Summary
[none] HttpError Multiple implementations:
  1. Constructor.
  2. Constructor.
  3. Constructor.
const Headers& getHeaders Get headers

# HttpError::HttpError

  1. Constructor.
    • @param info
    • @param message
    HttpError(const Info& info, const oatpp::String& message)
      : protocol::ProtocolError<Status>(info, message)
    
  2. Constructor.
    • @param status
    • @param message
    HttpError(const Status& status, const oatpp::String& message)
      : protocol::ProtocolError<Status>(Info(0, status), message)
    
  3. Constructor.
    • @param status
    • @param message
    • @param headers
    HttpError(const Status& status, const oatpp::String& message, const Headers& headers)
      : protocol::ProtocolError<Status>(Info(0, status), message)
      , m_headers(headers)
    

# HttpError::getHeaders

Get headers

  • @return

const Headers& getHeaders() const

# OATPP_ASSERT_HTTP

Throw HttpError if assertion failed.

  • @param COND - boolean statement. If evaluates to false - throw error.
  • @param STATUS - Status.
  • @param MESSAGE - String message.

#define OATPP_ASSERT_HTTP(COND, STATUS, MESSAGE)

Collection of HTTP Header constants.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class Header {}
}}}}

# Header::Value

Possible values for headers.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class Header {
    class Value {}
  };
}}}}

# RequestStartingLine

Struct representing HTTP request starting line. Example request starting line: GET /path/to/resource/ HTTP/1.1.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  struct RequestStartingLine {}
}}}}

# Fields

Type Name Summary
oatpp::data::share::StringKeyLabel method Method as oatpp::data::share::StringKeyLabel.
oatpp::data::share::StringKeyLabel path Path as oatpp::data::share::StringKeyLabel.
oatpp::data::share::StringKeyLabel protocol Protocol as oatpp::data::share::StringKeyLabel.

# RequestStartingLine::method

Method as oatpp::data::share::StringKeyLabel.

oatpp::data::share::StringKeyLabel method

# RequestStartingLine::path

Path as oatpp::data::share::StringKeyLabel.

oatpp::data::share::StringKeyLabel path

# RequestStartingLine::protocol

Protocol as oatpp::data::share::StringKeyLabel.

oatpp::data::share::StringKeyLabel protocol

# ResponseStartingLine

Struct representing HTTP response starting line. Example response starting line: HTTP/1.1 200 OK.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  struct ResponseStartingLine {}
}}}}

# Fields

Type Name Summary
oatpp::data::share::StringKeyLabel protocol Protocol as oatpp::data::share::StringKeyLabel.
v_int32 statusCode Status code as v_int32.
oatpp::data::share::StringKeyLabel description Description as oatpp::data::share::StringKeyLabel.

# ResponseStartingLine::protocol

Protocol as oatpp::data::share::StringKeyLabel.

oatpp::data::share::StringKeyLabel protocol

# ResponseStartingLine::statusCode

Status code as v_int32.

v_int32 statusCode

# ResponseStartingLine::description

Description as oatpp::data::share::StringKeyLabel.

oatpp::data::share::StringKeyLabel description

# HeaderValueData

Data contained in the value of one header.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  struct HeaderValueData {}
}}}}

# Fields

Type Name Summary
std::unordered_set<data::share::StringKeyLabelCI> tokens value tokens.
std::unordered_map<data::share::StringKeyLabelCI, data::share::StringKeyLabel> titleParams Title params.

# Methods

Return Type Name Summary
oatpp::String getTitleParamValue Get title parm value by key.

# HeaderValueData::tokens

value tokens.

std::unordered_set<data::share::StringKeyLabelCI> tokens

# HeaderValueData::titleParams

Title params.

std::unordered_map<data::share::StringKeyLabelCI, data::share::StringKeyLabel> titleParams

# HeaderValueData::getTitleParamValue

Get title parm value by key.

  • @param key
  • @return

oatpp::String getTitleParamValue(const data::share::StringKeyLabelCI& key) const

# Parser

Oatpp Http parser.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class Parser {}
}}}}

# Methods

Return Type Name Summary
void parseRequestStartingLine Parse RequestStartingLine.
void parseResponseStartingLine Parse ResponseStartingLine.
void parseOneHeader Parse one header line. Example of the header line:
void parseHeaders Parse HTTP headers to Headers map.
void parseHeaderValueData Parse data that is contained in a one header.

# Parser::parseRequestStartingLine

Parse RequestStartingLine.

static void parseRequestStartingLine(RequestStartingLine& line,
                                     const std::shared_ptr<oatpp::base::StrBuffer>& headersText,
                                     oatpp::parser::Caret& caret,
                                     Status& error)

# Parser::parseResponseStartingLine

Parse ResponseStartingLine.

static void parseResponseStartingLine(ResponseStartingLine& line,
                                      const std::shared_ptr<oatpp::base::StrBuffer>& headersText,
                                      oatpp::parser::Caret& caret,
                                      Status& error)

# Parser::parseOneHeader

Parse one header line. Example of the header line: "Content-Type: application/json\r\n".

static void parseOneHeader(Headers& headers,
                           const std::shared_ptr<oatpp::base::StrBuffer>& headersText,
                           oatpp::parser::Caret& caret,
                           Status& error)

# Parser::parseHeaders

Parse HTTP headers to Headers map.

static void parseHeaders(Headers& headers,
                         const std::shared_ptr<oatpp::base::StrBuffer>& headersText,
                         oatpp::parser::Caret& caret,
                         Status& error)

# Parser::parseHeaderValueData

Parse data that is contained in a one header.

  • @param data - out. parsed data.
  • @param headerValue - header value string.
  • @param separator - subvalues separator.

static void parseHeaderValueData(HeaderValueData& data, const oatpp::data::share::StringKeyLabel& headerValue, v_char8 separator)

# Utils

Http utils.

namespace oatpp { namespace web { namespace protocol { namespace http { 
  class Utils {}
}}}}

# Methods

Return Type Name Summary
void writeHeaders Write headers map to stream.

# Utils::writeHeaders

Write headers map to stream.

  • @param headers
  • @param stream

static void writeHeaders(const Headers& headers, data::stream::ConsistentOutputStream* stream)