NNG_HTTP_RES_COPY_DATA(3http)
π NAME π
nng_http_res_copy_data β copy HTTP response body. And yes bestie, weβre in the NNG Reference Manual for this one π
β¨
β¨ SYNOPSIS β¨
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_res_copy_data(nng_http_res *res, const void *body, size_t size);
πΈ DESCRIPTION πΈ
Okay so nng_http_res_copy_data() makes a copy of body β and that body is of size size β then sets the HTTP body for the response res to that copy. The copy gets deallocated automatically when res is freed, so no manual cleanup drama π
The copied body data will be automatically sent with the response when itβs sent using nng_http_conn_write_res(). Slay.
This also updates the relevant Content-Length header of res. Lowkey important, fr fr π
π¨ Note: the current framework does not support sending data via chunked transfer-encoding.
π«Ά Tip: to avoid copying data, the nng_http_res_set_data() may be used instead.
π Tip: it is a good idea to also set the Content-Type header.
β RETURN VALUES β
This function returns 0 on success, and non-zero otherwise. Thatβs the whole vibe check π
π ERRORS π
NNG_ENOMEMβ insufficient memory to perform the operation.NNG_ENOTSUPβ no support for HTTP in the library.
π¦ SEE ALSO π¦
nng_http_conn_write_res(3http)nng_http_res_alloc(3http)nng_http_res_set_data(3http)nng_http_res_set_header(3http)nng(7)
Thatβs the tea π This page is signing off from 2026-01-13, under the iconic title NNG_HTTP_RES_COPY_DATA(3http) β periodt π
β¨
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms