NE_GET_RESPONSE_HEAD(3)
β¨ NE_GET_RESPONSE_HEAD(3) β¨
okay so bestie, this is a page from the neon API reference and it's literally all about peeking at what the server sent back to you β the response headers and those sneaky little trailer fields. four functions, one glow-up. let's go π
πΈ NAME πΈ
ne_get_response_header, ne_get_response_trailer, ne_response_header_iterate, ne_response_trailer_iterate β the functions that let you get at response headers and trailers π
π¦ SYNOPSIS π¦
#include <ne_request.h>
const char *ne_get_response_header(ne_request *request,
const char *name);
const char *ne_get_response_trailer(ne_request *req, const char *name);
void *ne_response_header_iterate(ne_request *request, void *cursor,
const char **name, const char **value);
void *ne_response_trailer_iterate(ne_request *request, void *cursor,
const char **name,
const char **value);
π DESCRIPTION π
So you wanna know the value of a response header field? iconic. use ne_get_response_header and just hand it the name of the header you want back. and like β important detail β if the server sends you multiple HTTP response headers with the same name, their values get smushed together into one comma-separated list. so you're not losing anything, it's giving "all my girls in one group chat" energy π«Ά
now for the plot twist: trailer fields. those are headers that arrive after the response body, not before β chunked responses only, iykyk. to grab one of those bad boys you use ne_get_response_trailer. otherwise it's literally the same semantics as ne_get_response_header. but fr fr, trailer fields are used rarely and you should interpret them with care β check RFC 9110 Β§6.5 for the whole story (link's down in REFERENCES, don't worry π).
want to see every header instead of just one? that's ne_response_header_iterate. it takes a cursor parameter which should be <italic>NULL</italic> to get the first header. it stores the name and value of the next header in the name and value parameters, and returns you a fresh new cursor pointer β pass that back into ne_response_header_iterate to get the next one. rinse, repeat, slay β¨
and ne_response_trailer_iterate? same exact semantics as ne_response_header_iterate, except it operates on the response trailer fields instead of the header section. one twin is a header girlie, the other is a trailer girlie. π«
π RETURN VALUE π
ne_get_response_header and ne_get_response_trailer each return a string β or NULL if no header or trailer field with that name was found (rip, nothing there π).
β οΈ the returned pointer is only valid until the next call tone_begin_requestorne_request_destroyfor the same request. do NOT be out here holding onto it forever, it will not survive. π
likewise, the cursor, names, and values you get back from ne_response_header_iterate or ne_response_trailer_iterate are only valid until the next call to ne_begin_request, or until the request object is destroyed. same energy, same expiry date. π
π EXAMPLES π
this little snippet will output the value of the Last-Modified header for a resource. main character code honestly:
ne_request *req = ne_request_create(sess, "GET", "/foo.txt");
if (ne_request_dispatch(req) == NE_OK) {
const char *mtime = ne_get_response_header(req, "Last-Modified");
if (mtime) {
printf("/foo.txt has last-modified value %s\n", mtime);
}
}
ne_request_destroy(req);
β HISTORY β
ne_get_response_trailer and ne_response_trailer_iterate are available in neon 0.37.0 and later. in older releases, trailer fields were just merged in with the normal response headers, so you could reach them with ne_get_response_header or ne_response_header_iterate. glow-up for the trailer girlies π§
π SEE ALSO π
ne_request_create(3), ne_request_destroy(3).
π COPYRIGHT π
Copyright Β© 2001-2026 Joe Orton
π REFERENCES π
and that's the whole page bestie! this was neon, dated 03/20/2026, and the page you're on is NE_GET_RESPONSE_HEAD(3). go read your headers, stay hydrated, and remember: the pointer expires. always. π
π¦β¨
π¦ where this page comes from
- arch rolling: neon 0.37.1-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms