sess.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <refentry id="refsess">
  2. <refmeta>
  3. <refentrytitle>ne_session_create</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_session_create">ne_session_create</refname>
  8. <refname id="ne_close_connection">ne_close_connection</refname>
  9. <refname id="ne_session_destroy">ne_session_destroy</refname>
  10. <refpurpose>set up HTTP sessions</refpurpose>
  11. </refnamediv>
  12. <refsynopsisdiv>
  13. <funcsynopsis>
  14. <funcsynopsisinfo>#include &lt;ne_session.h&gt;</funcsynopsisinfo>
  15. <funcprototype>
  16. <funcdef>ne_session *<function>ne_session_create</function></funcdef>
  17. <paramdef>const char *<parameter>scheme</parameter></paramdef>
  18. <paramdef>const char *<parameter>hostname</parameter></paramdef>
  19. <paramdef>unsigned int <parameter>port</parameter></paramdef>
  20. </funcprototype>
  21. <funcprototype>
  22. <funcdef>void <function>ne_close_connection</function></funcdef>
  23. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  24. </funcprototype>
  25. <funcprototype>
  26. <funcdef>void <function>ne_session_destroy</function></funcdef>
  27. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  28. </funcprototype>
  29. </funcsynopsis>
  30. </refsynopsisdiv>
  31. <refsect1>
  32. <title>Description</title>
  33. <para>An <type>ne_session</type> object represents an HTTP
  34. session - a logical grouping of a sequence of HTTP requests made to a
  35. certain server. Any requests made using the session can use a
  36. persistent connection, share cached authentication credentials and any
  37. other common attributes.</para>
  38. <para>A new HTTP session is created using the
  39. <function>ne_session_create</function> function; the
  40. <parameter>hostname</parameter> and <parameter>port</parameter>
  41. parameters specify the origin server to use, along with
  42. the <parameter>scheme</parameter> (usually <literal>"http"</literal>).
  43. Before the first use of <function>ne_session_create</function> in a
  44. process, <xref linkend="ne_sock_init"/> must have been called to
  45. perform any global initialization needed by any libraries used by
  46. &neon;.</para>
  47. <para>To enable SSL/TLS for the session, pass the string
  48. <literal>"https"</literal> as the <parameter>scheme</parameter>
  49. parameter, and either register a certificate verification function
  50. (see <xref linkend="ne_ssl_set_verify"/>) or trust the appropriate
  51. certificate (see <xref linkend="ne_ssl_trust_cert"/>, <xref
  52. linkend="ne_ssl_trust_default_ca"/>).</para>
  53. <para>To use a proxy server for the session, it must be
  54. configured (see <xref linkend="ne_session_proxy"/>) before any
  55. requests are created from session object.</para>
  56. <para>Further per-session options may be changed using the
  57. <xref linkend="ne_set_session_flag"/> interface.</para>
  58. <para>If it is known that the session will not be used for a
  59. significant period of time, <function>ne_close_connection</function>
  60. can be called to close the connection, if one remains open. Use of
  61. this function is entirely optional, but it must not be called if there
  62. is a request active using the session.</para>
  63. <para>Once a session has been completed,
  64. <function>ne_session_destroy</function> must be called to
  65. destroy the resources associated with the session. Any
  66. subsequent use of the session pointer produces undefined
  67. behaviour. The session object must not be destroyed until
  68. after all associated request objects have been
  69. destroyed.</para>
  70. </refsect1>
  71. <refsect1>
  72. <title>Notes</title>
  73. <para>The hostname passed to
  74. <function>ne_session_create</function> is resolved when the first
  75. request using the session is dispatched; a DNS resolution failure can
  76. only be detected at that time (using the <literal>NE_LOOKUP</literal>
  77. error code); see <xref linkend="ne_request_dispatch"/> for
  78. details.</para>
  79. </refsect1>
  80. <refsect1>
  81. <title>Return Values</title>
  82. <para><function>ne_session_create</function> will return
  83. a pointer to a new session object (and never &null;).</para>
  84. </refsect1>
  85. <refsect1>
  86. <title>Examples</title>
  87. <para>Create and destroy a session:</para>
  88. <programlisting>ne_session *sess;
  89. sess = ne_session_create("http", "host.example.com", 80);
  90. /* ... use sess ... */
  91. ne_session_destroy(sess);
  92. </programlisting>
  93. </refsect1>
  94. <refsect1>
  95. <title>See Also</title>
  96. <para><xref linkend="ne_ssl_set_verify"/>, <xref linkend="ne_ssl_trust_cert"/>, <xref linkend="ne_sock_init"/>, <xref linkend="ne_set_session_flag"/></para>
  97. </refsect1>
  98. </refentry>