1NE_GET_RESPONSE_HEAD(3) neon API reference NE_GET_RESPONSE_HEAD(3)
2
3
4
6 ne_get_response_header, ne_response_header_iterate - functions to
7 access response headers
8
10 #include <ne_request.h>
11
12 const char *ne_get_response_header(ne_request *request,
13 const char *name);
14
15 void *ne_response_header_iterate(ne_request *request, void *cursor,
16 const char **name,
17 const char **value);
18
20 To retrieve the value of a response header field, the
21 ne_get_response_header function can be used, and is given the name of
22 the header to return.
23
24 To iterate over all the response headers returned, the
25 ne_response_header_iterate function can be used. This function takes a
26 cursor parameter which should be NULL to retrieve the first header. The
27 function stores the name and value of the next header header in the
28 name and value parameters, and returns a new cursor pointer which can
29 be passed to ne_response_header_iterate to retrieve the next header.
30
32 ne_get_response_header returns a string, or NULL if no header with that
33 name was given. If used during request processing, the return value
34 pointer is valid only until the next call to ne_begin_request, or else,
35 until the request object is destroyed.
36
37 Likewise, the cursor, names, and values returned by
38 ne_response_header_iterate are only valid until the next call to
39 ne_begin_request or until the request object is destroyed.
40
42 The following code will output the value of the Last-Modified header
43 for a resource:
44
45 ne_request *req = ne_request_create(sess, "GET", "/foo.txt");
46 if (ne_request_dispatch(req) == NE_OK) {
47 const char *mtime = ne_get_response_header(req, "Last-Modified");
48 if (mtime) {
49 printf("/foo.txt has last-modified value %s\n", mtime);
50 }
51 }
52 ne_request_destroy(req);
53
55 ne_request_create, ne_request_destroy.
56
58 Joe Orton <neon@lists.manyfish.co.uk>
59 Author.
60
62neon 0.32.2 12 January 2022 NE_GET_RESPONSE_HEAD(3)