NNG_HTTP_REQ_SET_METHOD(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… nng_http_req_set_method β€” set HTTP request method

okay bestie, welcome to the 3http corner of the NNG Reference Manual ✨ this one's short and sweet and honestly? iconic behavior. it's the little function that tells your HTTP request who it is β€” like a vibe check but for methods πŸŽ€


🌸 SYNOPSIS 🌸

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

int nng_http_req_set_method(nng_http_req *req, const char *method);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. nng_http_req_set_method() sets the HTTP method associated with the request req to method. that's it, that's the whole thing 🫢

the method has to be a string, mmkay β€” stuff like "GET" or "POST" β€” and the HTTP specifications indicate that it must be upper case. lowercase is not the moment, i fear 😭

for newly allocated requests, the default value method is "GET" ⭐ which honestly makes sense, it's giving "i'm just here to read the timeline" energy.

also important: a local copy of the method is made in the request req πŸ‘‘ so you don't have to keep your string alive forever, no cap.


πŸ’– RETURN VALUES πŸ’–

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


πŸ”₯ ERRORS πŸ”₯

  • NNG_ENOMEM β€” insufficient memory to perform the operation 😭 the malloc said no and honestly same.
  • NNG_ENOTSUP β€” no support for HTTP in the library πŸ’€ like, this build of the library just doesn't do HTTP, sorry bestie.

🌈 SEE ALSO 🌈


and that's the whole page, bestie, we ate and left no crumbs πŸ“βœ¨ go forth and set your methods, uppercase only, iykyk πŸ’œ

sign-off wishes from the NNG Reference Manual (the 3http one, main character energy fr fr), dated 2026-01-13 β€” bye pookie πŸ§šβ€β™€οΈπŸŒΈ
πŸ“¦ where this page comes from