http.hpp file
Namespaces
- namespace nxt
- namespace nxt::io
- namespace nxt::io::http
Classes
- struct nxt::io::http::protocol_error
- Error raised for HTTP protocol parsing and transfer-framing failures.
- struct nxt::io::http::url
- Parsed URL pieces supported by the small HTTP client.
- struct nxt::io::http::response_start
- Response head returned after sending a request.
-
template <typename Reader>class nxt::io::http::http_body_reader
Functions
-
auto as_text(std::
span<const std:: byte> bytes) → std:: string_view - Reinterpret bytes as text.
-
auto has_header_token(const nxt::
http:: response_head& response, std:: string_view name, std:: string_view token) → bool - True when a comma-separated response header contains
token. -
auto header_value(const nxt::
http:: response_head& response, std:: string_view name) → std:: optional<std:: string_view> - Return the first matching response header value, case-insensitively.
- auto is_default_port(const url& url) → bool
- True when the URL uses its scheme's default port.
-
auto parse_chunk_size(std::
span<const std:: byte> line) → std:: size_t - Parse a hexadecimal chunk-size line.
-
auto parse_port(std::
string_view text) → std:: uint16_t - Parse a decimal TCP port.
-
auto parse_response_head(std::
span<const std:: byte> bytes) → nxt:: http:: response_head - Parse bytes up to an HTTP response-head boundary.
-
template <typename Reader>auto parse_sse_event(Reader& reader) → nxt::
task<std:: optional<nxt:: http:: server_sent_event>> -
auto parse_url(std::
string_view text) → url - Parse an HTTP or HTTPS URL into connection and request-target pieces.
-
template <typename Reader, typename OnChunk>auto read_chunked(Reader& reader, OnChunk on_chunk) → nxt::
task - Read a chunked transfer-encoded body.
-
template <typename Reader, typename OnChunk>auto read_content_length(Reader& reader, std::
size_t content_length, OnChunk on_chunk) → nxt:: task - Read exactly
content_lengthbytes and pass chunks toon_chunk. -
template <typename Reader>auto read_expected_crlf(Reader& reader) → nxt::
task - Read and validate an expected CRLF after chunk data.
-
template <typename Reader, typename OnChunk>auto read_response_body(Reader& reader, const response_start& response, OnChunk on_chunk) → nxt::
task - Read the response body as chunks.
-
template <typename Reader, typename OnChunk>auto read_response_body_chunks(Reader& reader, const nxt::
http:: response_head& response, OnChunk on_chunk) → nxt:: task - Dispatch to the body reader required by the response headers.
-
template <typename Reader>auto read_response_text(Reader& reader, const response_start& response) → nxt::
task<std:: string> - Read the full response body into a string.
-
template <typename Reader, typename OnChunk>auto read_until_eof(Reader& reader, OnChunk on_chunk) → nxt::
task - Read body bytes until the connection ends.
-
auto response_content_length(const nxt::
http:: response_head& response) → std:: optional<std:: size_t> - Parsed Content-Length header, when present.
-
auto response_content_type_is(const nxt::
http:: response_head& response, std:: string_view expected) → bool - True when the response Content-Type matches the expected media type.
-
auto response_is_chunked(const nxt::
http:: response_head& response) → bool - True when the response uses chunked transfer encoding.
-
auto response_status_is_success(const nxt::
http:: response_head& response) → bool - True for 2xx response status codes.
-
auto response_status_text(const nxt::
http:: response_head& response) → std:: string - Human-readable response status line.
-
template <typename Transport, typename Reader>auto send_request(Transport& transport, Reader& reader, const nxt::
http:: request& request) → nxt:: task<response_start> - Write a request and parse the response head.