Fastly Compute C++ SDK
Loading...
Searching...
No Matches

#include <body.h>

Inheritance diagram for fastly::http::Body:

Public Member Functions

 Body ()
 Get a new, empty HTTP body.
 Body (Body &&old)
 Body (std::vector< uint8_t > body_vec)
 Body (std::string body_str)
 Body (const char *body_str)
 Body (std::string_view body_str)
fastly::expected< size_t > read (uint8_t *buf, size_t bufsize)
fastly::expected< size_t > write (uint8_t *buf, size_t bufsize)
void append (Body other)
 Append another body onto the end of this body.
fastly::expected< void > append_trailer (std::string_view header_name, std::string_view header_value)
 Appends request or response trailers to the body.
std::string take_body_string ()
 Take the entire body as a string.

Protected Member Functions

int underflow ()
int overflow (int_type val)
int sync ()

Detailed Description

An HTTP body that can be read from, written to, or appended to another body.

The most efficient ways to read from and write to the body are through the [iostreams] implementations. If you want a non-panicking interface, you can use Body::read and Body::write directly, instead.

Read and write operations to a [Body] are automatically buffered.

Examples
async_reqs.cpp, clock.cpp, device_detection.cpp, ngwaf_inspect.cpp, random.cpp, and router.cpp.

Constructor & Destructor Documentation

◆ Body() [1/6]

fastly::http::Body::Body ( )
inline

Get a new, empty HTTP body.

◆ Body() [2/6]

fastly::http::Body::Body ( Body && old)
inline

◆ Body() [3/6]

fastly::http::Body::Body ( std::vector< uint8_t > body_vec)
inline

◆ Body() [4/6]

fastly::http::Body::Body ( std::string body_str)
inline

◆ Body() [5/6]

fastly::http::Body::Body ( const char * body_str)
inline

◆ Body() [6/6]

fastly::http::Body::Body ( std::string_view body_str)
inline

Member Function Documentation

◆ append()

void fastly::http::Body::append ( Body other)

Append another body onto the end of this body.

◆ append_trailer()

fastly::expected< void > fastly::http::Body::append_trailer ( std::string_view header_name,
std::string_view header_value )

Appends request or response trailers to the body.

◆ overflow()

int fastly::http::Body::overflow ( int_type val)
protected

◆ read()

fastly::expected< size_t > fastly::http::Body::read ( uint8_t * buf,
size_t bufsize )

Read bytes from the body, and return the number of bytes read. Bytes read will be 0 when the Body is or has become empty.

Unlike operator<<, this operation will return a fastly::unexpected<FastlyError> that can then be handled if the read itself fails, instead of aborting the entire process.

◆ sync()

int fastly::http::Body::sync ( )
protected

◆ take_body_string()

std::string fastly::http::Body::take_body_string ( )
inline

Take the entire body as a string.

◆ underflow()

int fastly::http::Body::underflow ( )
protected

◆ write()

fastly::expected< size_t > fastly::http::Body::write ( uint8_t * buf,
size_t bufsize )

Write bytes to the end of this body, and return the number of bytes written. Bytes written will be 0 on EOF.

Unlike operator<<, this operation will return a fastly::unexpected<FastlyError> that can then be handled if the write itself fails, instead of aborting the entire process.


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