| 1 |
<refentry id="refresphdr"> |
| 2 |
|
| 3 |
<refmeta> |
| 4 |
<refentrytitle>ne_get_response_header</refentrytitle> |
| 5 |
<manvolnum>3</manvolnum> |
| 6 |
</refmeta> |
| 7 |
|
| 8 |
<refnamediv> |
| 9 |
<refname id="ne_get_response_header">ne_get_response_header</refname> |
| 10 |
<refname id="ne_response_header_iterate">ne_response_header_iterate</refname> |
| 11 |
<refpurpose>functions to access response headers</refpurpose> |
| 12 |
</refnamediv> |
| 13 |
|
| 14 |
<refsynopsisdiv> |
| 15 |
|
| 16 |
<funcsynopsis> |
| 17 |
|
| 18 |
<funcsynopsisinfo>#include <ne_request.h></funcsynopsisinfo> |
| 19 |
|
| 20 |
<funcprototype> |
| 21 |
<funcdef>const char *<function>ne_get_response_header</function></funcdef> |
| 22 |
<paramdef>ne_request *<parameter>request</parameter></paramdef> |
| 23 |
<paramdef>const char *<parameter>name</parameter></paramdef> |
| 24 |
</funcprototype> |
| 25 |
|
| 26 |
<funcprototype> |
| 27 |
<funcdef>void *<function>ne_response_header_iterate</function></funcdef> |
| 28 |
<paramdef>ne_request *<parameter>request</parameter></paramdef> |
| 29 |
<paramdef>void *<parameter>cursor</parameter></paramdef> |
| 30 |
<paramdef>const char **<parameter>name</parameter></paramdef> |
| 31 |
<paramdef>const char **<parameter>value</parameter></paramdef> |
| 32 |
</funcprototype> |
| 33 |
|
| 34 |
</funcsynopsis> |
| 35 |
|
| 36 |
</refsynopsisdiv> |
| 37 |
|
| 38 |
<refsect1> |
| 39 |
<title>Description</title> |
| 40 |
|
| 41 |
<para>To retrieve the value of a response header field, the |
| 42 |
<function>ne_get_response_header</function> function can be used, |
| 43 |
and is given the name of the header to return.</para> |
| 44 |
|
| 45 |
<para>To iterate over all the response headers returned, the |
| 46 |
<function>ne_response_header_iterate</function> function can be |
| 47 |
used. This function takes a <parameter>cursor</parameter> |
| 48 |
parameter which should be &null; to retrieve the first header. The |
| 49 |
function stores the name and value of the next header header in |
| 50 |
the <parameter>name</parameter> and <parameter>value</parameter> |
| 51 |
parameters, and returns a new cursor pointer which can be passed |
| 52 |
to <function>ne_response_header_iterate</function> to retrieve the |
| 53 |
next header.</para> |
| 54 |
|
| 55 |
</refsect1> |
| 56 |
|
| 57 |
<refsect1> |
| 58 |
<title>Return value</title> |
| 59 |
|
| 60 |
<para><function>ne_get_response_header</function> returns a |
| 61 |
string, or &null; if no header with that name was given. If used |
| 62 |
during request processing, the return value pointer is valid only |
| 63 |
until the next call to <function>ne_begin_request</function>, or |
| 64 |
else, until the request object is destroyed.</para> |
| 65 |
|
| 66 |
<para>Likewise, the cursor, names, and values returned by |
| 67 |
<function>ne_response_header_iterate</function> are only valid |
| 68 |
until the next call to <function>ne_begin_request</function> or |
| 69 |
until the request object is destroyed.</para> |
| 70 |
|
| 71 |
</refsect1> |
| 72 |
|
| 73 |
<refsect1> |
| 74 |
<title>Examples</title> |
| 75 |
|
| 76 |
<para>The following code will output the value of the |
| 77 |
<literal>Last-Modified</literal> header for a resource:</para> |
| 78 |
|
| 79 |
<programlisting>ne_request *req = ne_request_create(sess, "GET", "/foo.txt"); |
| 80 |
if (ne_request_dispatch(req) == NE_OK) { |
| 81 |
const char *mtime = ne_get_response_header(req, "Last-Modified"); |
| 82 |
if (mtime) { |
| 83 |
printf("/foo.txt has last-modified value %s\n", mtime); |
| 84 |
} |
| 85 |
} |
| 86 |
ne_request_destroy(req);</programlisting> |
| 87 |
|
| 88 |
</refsect1> |
| 89 |
|
| 90 |
<refsect1> |
| 91 |
<title>See also</title> |
| 92 |
|
| 93 |
<para><xref linkend="ne_request_create"/>, <xref |
| 94 |
linkend="ne_request_destroy"/>.</para> |
| 95 |
</refsect1> |
| 96 |
|
| 97 |
</refentry> |
| 98 |
|