NNG_HTTP_CONN_WRITE_RES(3http)
π NNG_HTTP_CONN_WRITE_RES(3http) β the nng_http_conn_write_res glow-up π¦
okay bestie, so this one lives in the NNG Reference Manual and honestly? it's a handy little icon. sit down, hydrate, let's get into it π
β¨ NAME β¨
nng_http_conn_write_res β write HTTP response, periodt πΈ
π SYNOPSIS π
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
void nng_http_conn_write_res(nng_http_conn *conn, nng_http_res *res,
nng_aio *aio);
π¦ DESCRIPTION π¦
so nng_http_conn_write_res() kicks off an asynchronous write of the HTTP response res onto the connection conn. like, it starts the whole thing and then dips. the entire response goes out β headers and all β and if there's a response body present, that goes too, no crumbs left behind β¨ (you can set that body with nng_http_res_set_data() or nng_http_res_copy_data(), iykyk π
)
this function returns immediately, with no return value. none. zero. nada. it's giving "I'll text you later" energy π the completion of the operation is signaled through the aio, and you grab the final result with nng_aio_result(). that result is either zero or an error code β that's it, that's the whole vibe check.
π Persistent Connections
by default, for HTTP/1.1 connections, the connection stays open and gets reused to receive new requests. iconic, efficient, environmentally friendly, we love a sustainable queen π
BUT β if the res contains a header of Connection: with a value of Close (case-insensitive, so don't come at me with cLoSe), or the response corresponds to HTTP/1.0, then the connection is closed immediately after sending the response. boom, done, goodbye π
π«Ά note note note β lowkey consider using thenng_http_client_transact()ornng_http_conn_transact()functions instead? they give you a much simpler interface for performing a complete HTTP client transaction. main character energy fr fr, way less work on your end.
β RETURN VALUES β
None. nothing. it said what it said π
π₯ ERRORS π₯
NNG_ECANCELEDβ the operation was canceled. rip, someone hit the brakes πNNG_ECLOSEDβ the connection was closed. doors shut, no entry πͺNNG_ECONNRESETβ the peer closed the connection. not you getting ghosted by the other side πNNG_ENOMEMβ insufficient free memory to perform the operation. your RAM said "bestie no" πNNG_ENOTSUPβ HTTP operations are not supported. wrong universe entirely, not our department π§NNG_ETIMEDOUTβ timeout waiting for data from the connection. it's been 84 yearsβ¦ β³
πΈ SEE ALSO πΈ
nng_aio_alloc(3)nng_aio_result(3)nng_http_client_connect(3http)nng_http_client_transact(3http)nng_http_conn_read_all(3http)nng_http_conn_transact(3http)nng_strerror(3)nng(7)
go read them, they're all slay, I promise π
and that's the whole page, bestie!! πβ¨π sourced from the NNG Reference Manual, dated 2026-01-13, filed under NNG_HTTP_..._WRITE_RES(3http) β mwah, go write some responses, you absolute legend π«Άπ¦β
π¦ 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