NNG_HTTP_REQ_COPY_DATA(3http)
π NNG_HTTP_REQ_COPY_DATA(3http) π
okay bestie, welcome to the NNG Reference Manual β this is the NNG_HTTP_REQ_COPY_DATA(3http) page, and it's literally all about copying an HTTP request body. it's giving "set it and forget it" energy, no cap. π«Ά
πΈ NAME πΈ
nng_http_req_copy_data β copy HTTP request body. that's the whole vibe. π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_req_copy_data(nng_http_req *req, const void *body, size_t size);
π DESCRIPTION π
so nng_http_req_copy_data() makes a copy of body (of size size) and sets the HTTP body for the request req to it. the copy gets deallocated automatically when req is freed β no manual cleanup, periodt. β¨
when you send the request using nng_http_conn_write_req(), the copied body data will be automatically sent with it. yes bestie, it travels with the request. π¦
this also updates the relevant Content-Length header of req. so the numbers stay cute and correct. π
π Note: the current framework does not support sending data via chunked transfer-encoding. so don't try to make fetch happen with chunked transfer-encoding, bestie π
β¨ Tip: to avoid copying data, nng_http_req_set_data() may be used instead. that's the avoid-the-copy route, iykyk.
π Tip: it is a good idea to also set the Content-Type header. do it for the vibe check β and because it's a good idea, duh. π
π«Ά RETURN VALUES π«Ά
this function returns 0 on success, and non-zero otherwise. slay when it's 0, side-eye when it's not. π
π¨ ERRORS π¨
NNG_ENOMEMβ insufficient memory to perform the operation. your RAM said "not today" πNNG_ENOTSUPβ no support for HTTP in the library. HTTP is not in this library's group chat, fr fr π
π SEE ALSO π
nng_http_conn_write_req(3http)nng_http_req_alloc(3http)nng_http_req_set_data(3http)nng_http_req_set_header(3http)nng(7)
xoxo, your fave manual page π
β from the NNG Reference Manual, dated 2026-01-13, page NNG_HTTP_REQ_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