Represents an incoming HTTP/1.1 request. More...
#include <httpd.hpp>
Public Member Functions | |
| TRequest (std::string &&header, std::function< TFuture< ssize_t >(char *, size_t)> bodyReader, std::function< TFuture< std::string >()> chunkHeaderReader={}) | |
| std::string_view | Method () const |
HTTP method string (e.g. "GET", "POST"). | |
| const TUri & | Uri () const |
| Parsed request URI. | |
| std::string_view | Version () const |
HTTP version string (e.g. "HTTP/1.1"). | |
| bool | HasBody () const |
Returns true if the request has a body (non-zero Content-Length or chunked). | |
| TFuture< std::string > | ReadBodyFull () |
| Reads and returns the entire request body as a string. | |
| TFuture< ssize_t > | ReadBodySome (char *buffer, size_t size) |
Reads up to size bytes of the request body into buffer. | |
| bool | BodyConsumed () const |
Returns true once the full body has been read. | |
| bool | RequireConnectionClose () const |
Returns true if the client sent Connection: close or is HTTP/1.0. | |
| const std::map< std::string_view, std::string_view > & | Headers () const |
All request headers as a name → value map (views into the header buffer). | |
Represents an incoming HTTP/1.1 request.
Constructed by TWebServer from the parsed request headers and a body-reader callback. The body is read lazily — call ReadBodyFull() or ReadBodySome() to consume it. Both Content-Length and chunked transfer encoding are supported.
Header string views (Method(), Version(), values in Headers()) reference the internal header buffer and are valid for the lifetime of this object.
| TFuture< std::string > NNet::TRequest::ReadBodyFull | ( | ) |
Reads and returns the entire request body as a string.
Buffers all data up to Content-Length or until the final chunk. Throws on connection close before body is complete.
| TFuture< ssize_t > NNet::TRequest::ReadBodySome | ( | char * | buffer, |
| size_t | size | ||
| ) |
Reads up to size bytes of the request body into buffer.
Returns bytes read, 0 at end-of-body, or a negative retry hint. Respects Content-Length and chunked encoding transparently.