Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::http::HttpParser Class Reference

Utility class for parsing HTTP requests and related components. More...

#include <HttpParser.hpp>

Static Public Member Functions

static std::optional< HttpRequest > parse (std::string_view raw_request)
 Parses one complete HTTP/1.1 request held in memory.
 
static HttpMethod parse_method (std::string_view method_str)
 Parses an HTTP method string into an HttpMethod enum value.
 

Detailed Description

Utility class for parsing HTTP requests and related components.

Member Function Documentation

◆ parse()

static std::optional< HttpRequest > orbit::http::HttpParser::parse ( std::string_view  raw_request)
static

Parses one complete HTTP/1.1 request held in memory.

Uses Http1Parser (llhttp), with the same strict rules and default limits as a connection. The request owns its headers and body, so it outlives raw_request. Anything after the first request is ignored.

Parameters
raw_requestThe raw request, including any body.
Returns
The request, or std::nullopt if it is malformed or incomplete.

◆ parse_method()

static HttpMethod orbit::http::HttpParser::parse_method ( std::string_view  method_str)
static

Parses an HTTP method string into an HttpMethod enum value.

Parameters
method_strThe string representation of the HTTP method (e.g., "GET").
Returns
The corresponding HttpMethod enum value, or HttpMethod::UNKNOWN if not recognized.

The documentation for this class was generated from the following file: