dot-xx
A personal collection of small C++ modules
Loading...
Searching...
No Matches
dxx.http Module Reference

A feature-poor HTTP server implementation. More...

Classes

struct  dxx::http::ServerError
 Exception class that supports construction from a format-like args and automatic errno capture in the message. More...
struct  dxx::http::StreamError
struct  dxx::http::RequestError
class  dxx::http::PathNode< TData >
class  dxx::http::Server
 A simple HTTP server. More...
class  dxx::http::PendingConnection< TResponse >
 An awaitable object that allows the handler code to respond to the request at a later point in time. More...
struct  dxx::http::Request
 HTTP request structure. Also used for multipart request data. More...
struct  dxx::http::Response
 Server's response to the client. More...

Enumerations

enum class  dxx::http::Method {
  Invalid , Get , Head , Post ,
  Put , Delete , Connect , Options ,
  Trace , Patch
}
enum class  dxx::http::HeaderError {
  None , Method , Header , Unterminated ,
  StrayData
}
 An error during HTTP request header parsing. More...
enum class  dxx::http::MultipartError {
  NotMultipart , Unterminated , NoPartBody , UnterminatedHeader ,
  InvalidHeader
}
 An error during parsing of a multipart request. More...
enum class  StatusCode {
  Continue = 100 , SwitchingProtocols = 101 , Processing = 102 , EarlyHints = 103 ,
  OK = 200 , Created = 201 , Accepted = 202 , NonAuthoritativeInformation = 203 ,
  NoContent = 204 , ResetContent = 205 , PartialContent = 206 , MultiStatus = 207 ,
  AlreadyReported = 208 , IMUsed = 226 , MultipleChoices = 300 , MovedPermanently = 301 ,
  Found = 302 , SeeOther = 303 , NotModified = 304 , UseProxy = 305 ,
  TemporaryRedirect = 307 , PermanentRedirect = 308 , BadRequest = 400 , Unauthorized = 401 ,
  PaymentRequired = 402 , Forbidden = 403 , NotFound = 404 , MethodNotAllowed = 405 ,
  NotAcceptable = 406 , ProxyAuthenticationRequired = 407 , RequestTimeout = 408 , Conflict = 409 ,
  Gone = 410 , LengthRequired = 411 , PreconditionFailed = 412 , ContentTooLarge = 413 ,
  URITooLong = 414 , UnsupportedMediaType = 415 , RangeNotSatisfiable = 416 , ExpectationFailed = 417 ,
  ImATeapot = 418 , MisdirectedRequest = 421 , UnprocessableContent = 422 , Locked = 423 ,
  FailedDependency = 424 , TooEarly = 425 , UpgradeRequired = 426 , PreconditionRequired = 428 ,
  TooManyRequests = 429 , RequestHeaderFieldsTooLarge = 431 , UnavailableForLegalReasons = 451 , InternalServerError = 500 ,
  NotImplemented = 501 , BadGateway = 502 , ServiceUnavailable = 503 , GatewayTimeout = 504 ,
  HTTPVersionNotSupported = 505 , VariantAlsoNegotiates = 506 , InsufficientStorage = 507 , LoopDetected = 508 ,
  NotExtended = 510 , NetworkAuthenticationRequired = 511
}

Functions

StringMap dxx::http::parse_content_disposition (std::string_view data)
 Parse Content-Disposition header.
constexpr std::string dxx::http::url::decode (std::string_view encoded)
constexpr std::string dxx::http::url::encode (std::string_view decoded)

Variables

const std::flat_map< std::string_view, Methoddxx::http::methods_map
const std::unordered_map< std::string, std::string > dxx::http::mime_types
 Mappings of some file extensions to their corresponding content type.

Detailed Description

A feature-poor HTTP server implementation.

Implements the server on top of C++20 coroutines which results in a relatively extensible approach, supporting e.g. long polling

See https://github.com/GregTheMadMonk/dot-xx/blob/http/example/main.cc to see what this library is capable of

Files

file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/http.xx
 Main interface file for dxx.http module.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/coro.xx
 Coroutine types for the server.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/errors.xx
 HTTP server exception types.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/message.xx
 Request and Response types
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/method.xx
 HTTP methods enum and strings.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/mime.xx
 Built-in mime-type mappings.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/path.xx
 The server's path matching.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/server.xx
 A simple HTTP server.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/status_codes.xx
 HTTP status codes enum.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/url.xx
 URL encoding and decoding.
file  /build-llvm-libcpp/_deps/dot-xx-http-src/src/utils.xx
 Misc utility code.