|
Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
|
Namespaces | |
| namespace | h2 |
| namespace | websocket |
Classes | |
| class | Client |
| Asynchronous HTTP/1.1 and HTTP/2 client (libcurl's multi interface). More... | |
| struct | ClientOptions |
| struct | ClientRequest |
| An outbound HTTP request for Client. More... | |
| struct | ClientResponse |
| The result of a ClientRequest. More... | |
| struct | ClientSendAwaiter |
| co_await Client::send_async(...): resumes with the ClientResponse. More... | |
| struct | Cookie |
| Represents an HTTP cookie. More... | |
| class | Http1Parser |
| Incremental HTTP/1.1 request parser, built on llhttp (the parser Node.js uses). More... | |
| class | HttpParser |
| Utility class for parsing HTTP requests and related components. More... | |
| struct | HttpRequest |
| Represents an incoming HTTP request. More... | |
| class | HttpResponse |
| Represents an HTTP response to be sent to a client. More... | |
| struct | MultipartFile |
| Represents a file uploaded via multipart/form-data. More... | |
| class | MultipartForm |
| Represents parsed multipart/form-data content. More... | |
| struct | MultipartLimits |
| Limits for MultipartStreamParser. Exceeding one fails the parse (see MultipartStreamParser::failed()) and deletes the partial file. More... | |
| class | MultipartStreamParser |
| Streaming parser for multipart/form-data. More... | |
| struct | MultipartUpload |
| The result of receive_multipart(). More... | |
| class | RequestContext |
| Type-indexed, per-request storage: middleware that computes something for later middleware or the handler (the authenticated user, a tenant, a DB transaction, request timing) stashes it here instead of a header, a global, or a new fixed field on HttpRequest. More... | |
| class | ResponseWriter |
| Abstract interface for writing HTTP responses. More... | |
| struct | UploadedFile |
| A file part saved to disk by receive_multipart(). More... | |
Functions | |
| bool | connection_option_present (std::string_view field_value, std::string_view option) |
| Tests whether a Connection header field carries a given option. | |
| bool | percent_decode (std::string_view in, std::string &out, bool plus_as_space, bool for_path) |
| Decodes XX escapes (RFC 3986 section 2.1). | |
| bool | parse_urlencoded (std::string_view data, std::unordered_map< std::string, std::string > &out) |
| Decodes application/x-www-form-urlencoded data: a query string or a form body (WHATWG URL Standard section 5.1). | |
| void | parse_cookie_header (std::string_view cookie_header, std::unordered_map< std::string, std::string > &out) |
| template<typename T > | |
| std::optional< T > | parse_param (const std::string &text) |
| const char * | reason_phrase (int status_code) |
| Reason phrase for a status code. Codes without a registered phrase get a generic one for their class (e.g. "Client Error" for 4xx). | |
| bool | is_valid_header_name (std::string_view name) |
True if name is a valid header field name (an RFC 9110 token). | |
| bool | is_valid_header_value (std::string_view value) |
True if value can be written as a header field value: it contains no CR, LF or NUL, so it cannot start a new header line. | |
| std::string | format_http_date (std::time_t t) |
Formats t as an IMF-fixdate (RFC 9110 section 5.6.7), e.g. "Sun, 06 Nov 1994 08:49:37 GMT", independent of the C locale. | |
| std::string_view | http_date_now () |
| The current time as an IMF-fixdate, for the Date header. | |
| std::string | multipart_boundary (std::string_view content_type) |
Extracts the boundary parameter from a multipart Content-Type value, e.g. multipart/form-data; boundary="abc" (RFC 9110 section 5.6.6, RFC 2046 section 5.1.1). | |
| void | receive_multipart (const HttpRequest &req, std::shared_ptr< ResponseWriter > writer, std::function< void(MultipartUpload &)> on_complete, MultipartLimits limits={}) |
| Receives a multipart/form-data body, streaming file parts to disk. | |
|
strong |
|
strong |
Standard HTTP status codes.
| bool orbit::http::connection_option_present | ( | std::string_view | field_value, |
| std::string_view | option | ||
| ) |
Tests whether a Connection header field carries a given option.
The Connection header is a comma-separated list of case-insensitive tokens (RFC 9110 section 7.6.1), so a client may legitimately send Connection: keep-alive, TE or Connection: Close. Comparing the whole field value against a single token misses both.
| field_value | The raw Connection header value. |
| option | The option to look for, in lowercase (e.g. "close"). |
| std::string orbit::http::format_http_date | ( | std::time_t | t | ) |
Formats t as an IMF-fixdate (RFC 9110 section 5.6.7), e.g. "Sun, 06 Nov 1994 08:49:37 GMT", independent of the C locale.
| std::string_view orbit::http::http_date_now | ( | ) |
The current time as an IMF-fixdate, for the Date header.
Formatted at most once per second per thread and cached, so a response costs one clock read rather than a gmtime and a format. The view stays valid until the calling thread's next call.
| bool orbit::http::is_valid_header_name | ( | std::string_view | name | ) |
True if name is a valid header field name (an RFC 9110 token).
| bool orbit::http::is_valid_header_value | ( | std::string_view | value | ) |
True if value can be written as a header field value: it contains no CR, LF or NUL, so it cannot start a new header line.
| std::string orbit::http::multipart_boundary | ( | std::string_view | content_type | ) |
Extracts the boundary parameter from a multipart Content-Type value, e.g. multipart/form-data; boundary="abc" (RFC 9110 section 5.6.6, RFC 2046 section 5.1.1).
| void orbit::http::parse_cookie_header | ( | std::string_view | cookie_header, |
| std::unordered_map< std::string, std::string > & | out | ||
| ) |
Adds the name=value pairs of a Cookie header to out (a later pair with the same name wins).
| std::optional< T > orbit::http::parse_param | ( | const std::string & | text | ) |
Parses text as T (see HttpRequest::param); null if it does not parse as a T with nothing left over.
| bool orbit::http::parse_urlencoded | ( | std::string_view | data, |
| std::unordered_map< std::string, std::string > & | out | ||
| ) |
Decodes application/x-www-form-urlencoded data: a query string or a form body (WHATWG URL Standard section 5.1).
Pairs are separated by '&', names from values by the first '='; '+' is a space. A name without '=' gets an empty value, and a repeated name keeps its last value.
out may then hold earlier pairs. | bool orbit::http::percent_decode | ( | std::string_view | in, |
| std::string & | out, | ||
| bool | plus_as_space, | ||
| bool | for_path | ||
| ) |
Decodes XX escapes (RFC 3986 section 2.1).
| in | The encoded text. |
| out | Receives the decoded text. |
| plus_as_space | Decode '+' as a space (query strings / form data). |
| for_path | Reject escapes that would change how a path is split or read: %2F ('/'), %5C ('\') and %00. A request that hides a path separator in an escape is refused rather than guessed at. |
| const char * orbit::http::reason_phrase | ( | int | status_code | ) |
Reason phrase for a status code. Codes without a registered phrase get a generic one for their class (e.g. "Client Error" for 4xx).
| void orbit::http::receive_multipart | ( | const HttpRequest & | req, |
| std::shared_ptr< ResponseWriter > | writer, | ||
| std::function< void(MultipartUpload &)> | on_complete, | ||
| MultipartLimits | limits = {} |
||
| ) |
Receives a multipart/form-data body, streaming file parts to disk.
Use it from a stream route (Router::add_stream_route), so the body is not buffered in memory first. Fields are collected and files are written under limits.upload_dir as they arrive.
on_complete is called exactly once: at once if the Content-Type is not multipart/form-data with a boundary, otherwise when the body has ended. The result is a failure if a limit was exceeded or the body is malformed or truncated (no closing boundary); every file already saved is then deleted before the call.