NNG_HTTP_REQ_ALLOC(3http)

πŸ“¦ version 1.11, in alpine 3.24

✨ nng_http_req_alloc β€” allocate HTTP request structure ✨

okay so bestie, welcome to the NNG Reference Manual πŸ’– this page is all about making a brand-new HTTP request struct out of thin air (well, out of memory), and honestly it's giving "tiny little building block of the internet" energy. πŸŽ€


🌸 SYNOPSIS 🌸

#include <nng/nng.h>
#include <nng/supplemental/http/http.h>

int nng_http_req_alloc(nng_http_req **reqp, const nng_url *url);

like, that's the whole vibe. two includes, one function, zero drama. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so nng_http_req_alloc() allocates a shiny new HTTP request structure and stores a pointer to it in reqp. that's the out-param, she's the main character here πŸ‘‘

the request comes pre-initialized to perform an HTTP/1.1 GET operation, using the URL you pass in url. yes, it's already a GET, it already has a URL, it's ready to go, no cap. πŸ”₯

Tip πŸ’‘ β€” you can pass NULL for the URL! it's allowed! but then the URI for the request has to be set by a subsequent call to nng_http_req_set_uri(). so like, it's not illegal, it's just unfinished business β€” you're leaving her without an address until you fix that. πŸ™ˆ

πŸ’œ RETURN VALUES πŸ’œ

this function returns 0 on success, and non-zero otherwise. classic. short and sweet. slay. πŸ’…


⭐ ERRORS ⭐

  • NNG_ENOMEM β€” insufficient free memory exists to allocate a message. aka the allocator said "girl, no". 😭
  • NNG_ENOTSUP β€” HTTP support not configured. aka you didn't build with the HTTP stuff turned on, so this whole thing is a no-go. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

like, read them all, they're all icons. iykyk 🧚


okay bye bestie, hope your request allocates on the first try 🫢 this little page is from the NNG Reference Manual, dated 2026-01-13, and it's the NNG_HTTP_REQ_ALLOC(3http) page β€” go forth and GET responsibly πŸŒˆπŸ’–

πŸ“¦ where this page comes from