NNG_HTTP_REQ_COPY_DATA(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’– 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 πŸ”—


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