resphdr.xml 3.3 KB

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