NE_GET_RESPONSE_HEAD(3)
π NE_GET_RESPONSE_HEAD(3) β the neon API reference glow-up π
okay bestie, so this is a page from the neon API reference (that's the manual name, consider it folded in like a lil note in your lunchbox π). It's all about the functions that go digging around in your HTTP response headers and trailers. Four of them. They're a little family. Let's meet them β¨
β¨ NAME β¨
ne_get_response_header, ne_get_response_trailer, ne_response_header_iterate, ne_response_trailer_iterate β functions to access response headers and trailers
like literally the whole point of them. no notes. π
π¦ 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);
she's giving clean signatures π
πΈ DESCRIPTION πΈ
So you wanna know what a response header field says? Say less. You use ne_get_response_header, and you hand her the name of the header you're craving and she gives you the goods.
And listen β if multiple HTTP response headers come back with the same name (rude of them tbh), their values get combined together into one comma-separated list. All of them. Together. Besties holding hands. π«Ά
Now for the trailer era. If you want a header value from a chunked response trailer section β and yes, that's the part that gets sent after the response body instead of before it, iconic behaviour honestly β you use ne_get_response_trailer. Otherwise it's the exact same semantics as ne_get_response_header. Same vibes, different section.
β οΈ ok but fr: trailer fields are used rarely and you should interpret them with care. See RFC 9110 Β§6.5[1]. Not me warning you twice. π
Wanna iterate over all the response headers instead of just one? That's ne_response_header_iterate's whole moment. She takes a cursor parameter, and to get the first header you set that cursor to NULL. She stores the name and value of the next header into the name and value parameters, and she returns a new cursor pointer that you pass right back into ne_response_header_iterate to get the next header. Rinse, repeat, slay. β¨
And ne_response_trailer_iterate? Same semantics as ne_response_header_iterate, except she operates on the response trailer fields instead of the header section. Same energy, different section, you know the drill. π
π 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. Ghosted. Not found. That's the NULL.
π¨ Big important thing: the return value pointer is valid only until the next call tone_begin_requestorne_request_destroyfor the same request. Do not go keeping that pointer around like it's yours. It is not. It's temporary. It's giving situationship. π
Likewise, the cursor, names, and values returned by 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 rule, same energy, no cap. π
π EXAMPLES π
The following code will output the value of the Last-Modified header for a resource:
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);
look at her. so neat. so composed. she ate and left no crumbs π
β 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 merged with normal response headers and could be accessed using ne_get_response_header or ne_response_header_iterate. So if you're on an ancient version, that's why your trailer functions aren't picking up the phone. π
π SEE ALSO π
go read those too, they're the main characters of this whole saga π«Ά
π§ COPYRIGHT π§
Copyright Β© 2001-2026 Joe Orton
π₯ REFERENCES π₯
okay that's the whole page, you're fully caught up bestie π this was neon 0.37.1, dated 15 March 2026 β mwah, go forth and read your headers responsibly, periodt. πΈπ β¨
π¦ where this page comes from
- epel 10: neon-devel 0.37.1-4.el10_3 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- nixos 26.05: neon 0.37.1
- nixpkgs unstable: neon 0.37.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms