neon.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <refentry id="refneon">
  2. <refmeta>
  3. <refentrytitle>neon</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname>neon</refname>
  8. <refpurpose>HTTP and WebDAV client library</refpurpose>
  9. </refnamediv>
  10. <refsect1>
  11. <title>Description</title>
  12. <para>neon is an HTTP and WebDAV client library. The major
  13. abstractions exposed are the HTTP <emphasis>session</emphasis>,
  14. created by <xref linkend="ne_session_create"/>; and the HTTP
  15. <emphasis>request</emphasis>, created by <xref
  16. linkend="ne_request_create"/>. HTTP authentication is handled
  17. transparently for server and proxy servers, see <xref
  18. linkend="ne_set_server_auth"/>; complete SSL/TLS support is also
  19. included, see <xref linkend="ne_ssl_set_verify"/>.</para>
  20. </refsect1>
  21. <refsect1>
  22. <title>Conventions</title>
  23. <para>Some conventions are used throughout the neon API, to
  24. provide a consistent and simple interface; these are documented
  25. below.</para>
  26. <refsect2>
  27. <title>Thread-safeness and global initialization</title>
  28. <para>&neon; itself is implemented to be thread-safe (avoiding any
  29. use of global state), but relies on the operating system providing
  30. a thread-safe resolver interface. Modern operating systems offer
  31. the thread-safe <function>getaddrinfo</function> interface, which
  32. &neon; supports; some others implement
  33. <function>gethostbyname</function> using thread-local
  34. storage.</para>
  35. <para>To allow thread-safe use of SSL in the OpenSSL and GnuTLS
  36. libraries &neon; must be configured using the
  37. <literal>--enable-threadsafe-ssl</literal>; if this is done,
  38. locking callbacks will be registered by <xref
  39. linkend="ne_sock_init"/>; note that care must be exercised if
  40. &neon; is used in conjunction with another library which uses
  41. OpenSSL or GnuTLS.</para>
  42. <para>Some platforms and libraries used by &neon; require global
  43. initialization before use; notably:
  44. <itemizedlist>
  45. <listitem><simpara>The <literal>SIGPIPE</literal> signal
  46. disposition must be set to <emphasis>ignored</emphasis> or
  47. otherwise handled to avoid process termination when writing to a
  48. socket which has been shutdown by the peer.</simpara></listitem>
  49. <listitem><simpara>OpenSSL and GnuTLS require global
  50. initialization to load shared lookup
  51. tables.</simpara></listitem>
  52. <listitem><simpara>The Win32 socket library requires
  53. initialization before use.</simpara></listitem>
  54. </itemizedlist>
  55. The <xref linkend="ne_sock_init"/> function should be called
  56. before any other use of &neon; to perform any necessary
  57. initialization needed for the particular platform. Applications
  58. wishing to perform all the necessary process-global initialization
  59. steps themselves may omit to call <xref linkend="ne_sock_init"/>
  60. (and <xref linkend="ne_sock_exit"/>); &neon; neither checks whether
  61. these functions are called nor calls them itself.</para>
  62. <para>For some applications and configurations it may be necessary
  63. to call <xref linkend="ne_i18n_init"/> to initialize the support
  64. for internationalization in &neon;.</para>
  65. </refsect2>
  66. <refsect2>
  67. <title>Asynchronous signal safety</title>
  68. <para>No function in &neon; is defined to be <quote>async-signal safe</quote> -
  69. that is, no function is safe to call from a signal handler. Any
  70. call into the &neon; library from a signal handler will have
  71. undefined behaviour - in other words, it may crash the
  72. process.</para>
  73. </refsect2>
  74. <refsect2>
  75. <title>Functions using global state</title>
  76. <para>Any function in &neon; may modify the
  77. <literal>errno</literal> global variable as a side-effect. Except
  78. where explicitly documented, the value of <literal>errno</literal>
  79. is unspecified after any &neon; function call.</para>
  80. <para>Other than in the use of <literal>errno</literal>, the only
  81. functions which use or modify process-global state in &neon; are
  82. as follows:
  83. <itemizedlist>
  84. <listitem><simpara><xref linkend="ne_sock_init"/>, <xref
  85. linkend="ne_i18n_init"/>, and <xref linkend="ne_sock_exit"/>, as
  86. described above</simpara></listitem>
  87. <listitem><simpara><function>ne_debug_init</function> and
  88. <function>ne_debug</function>, if enabled at compile time; for
  89. debugging output</simpara></listitem>
  90. <listitem><simpara><xref linkend="ne_oom_callback"/> for
  91. installing a process-global callback to be invoked on
  92. <function>malloc</function> failure</simpara></listitem>
  93. </itemizedlist></para>
  94. </refsect2>
  95. <refsect2>
  96. <title>Namespaces</title>
  97. <para>To avoid possible collisions between names used for symbols
  98. and preprocessor macros by an application and the libraries it
  99. uses, it is good practice for each library to reserve a particular
  100. <emphasis>namespace prefix</emphasis>. An application which
  101. ensures it uses no names with these prefixes is then guaranteed to
  102. avoid such collisions.</para>
  103. <para>The &neon; library reserves the use of the namespace
  104. prefixes <literal>ne_</literal> and <literal>NE_</literal>. The
  105. libraries used by &neon; may also reserve certain namespaces;
  106. collisions between these libraries and a &neon;-based application
  107. will not be detected at compile time, since the underlying library
  108. interfaces are not exposed through the &neon; header files. Such
  109. collisions can only be detected at link time, when the linker
  110. attempts to resolve symbols. The following list documents some of
  111. the namespaces claimed by libraries used by &neon;; this list may
  112. be incomplete.</para>
  113. <variablelist>
  114. <varlistentry>
  115. <term>SSL, ssl, TLS, tls, ERR_, BIO_, d2i_, i2d_, ASN1_</term>
  116. <listitem><simpara>Some of the many prefixes used by the OpenSSL
  117. library; little attempt has been made to keep exported symbols
  118. within any particular prefixes for this
  119. library.</simpara></listitem>
  120. </varlistentry>
  121. <varlistentry>
  122. <term>gnutls_, gcry_, gpg_</term>
  123. <listitem><simpara>Namespaces used by the GnuTLS library (and
  124. dependencies thereof)</simpara></listitem>
  125. </varlistentry>
  126. <varlistentry>
  127. <term>XML_, Xml[A-Z]</term> <listitem><simpara>Namespaces
  128. used by the expat library.</simpara></listitem>
  129. </varlistentry>
  130. <varlistentry>
  131. <term>xml[A-Z], html[A-Z], docb[A-Z]</term>
  132. <listitem><simpara>Namespaces used by the libxml2 library; a
  133. relatively small number of symbols are used without these
  134. prefixes.</simpara></listitem>
  135. </varlistentry>
  136. <varlistentry>
  137. <term>inflate, deflate, crc32, compress, uncompress, adler32,
  138. zlib</term>
  139. <listitem><simpara>Namespaces used by the zlib library; a
  140. relatively small number of symbols are used without these
  141. prefixes.</simpara></listitem>
  142. </varlistentry>
  143. <varlistentry>
  144. <term>krb5, gss, GSS, asn1, decode_krb5, encode_krb5, profile,
  145. mit</term>
  146. <listitem><simpara>Some of the prefixes used by the MIT GSSAPI
  147. library and dependencies thereof; a number of symbols lie
  148. outside these prefixes.</simpara></listitem>
  149. </varlistentry>
  150. <varlistentry>
  151. <term>pakchois_</term>
  152. <listitem><simpara>Namespace used by the pakchois
  153. library.</simpara></listitem>
  154. </varlistentry>
  155. <varlistentry>
  156. <term>px_</term>
  157. <listitem><simpara>Namespace used by the libproxy
  158. library.</simpara></listitem>
  159. </varlistentry>
  160. </variablelist>
  161. </refsect2>
  162. <refsect2>
  163. <title>Argument validation</title>
  164. <para>&neon; does not attempt to validate that the parameters
  165. passed to functions conform to the API (for instance, checking
  166. that pointer arguments are not &null;). Any use of the &neon; API
  167. which is not documented to produce a certain behaviour results is
  168. said to produce <emphasis>undefined behaviour</emphasis>; it is
  169. likely that &neon; will segfault under these conditions.</para>
  170. </refsect2>
  171. <refsect2>
  172. <title>URI paths, WebDAV metadata</title>
  173. <para>The path strings passed to any function must be
  174. <emphasis>URI-encoded</emphasis> by the application; &neon; never
  175. performs any URI encoding or decoding internally. WebDAV property
  176. names and values must be valid UTF-8 encoded Unicode
  177. strings.</para>
  178. </refsect2>
  179. <refsect2>
  180. <title>User interaction</title>
  181. <para>As a pure library interface, &neon; will never produce
  182. output on <constant>stdout</constant> or
  183. <constant>stderr</constant>; all user interaction is the
  184. responsibility of the application.</para>
  185. </refsect2>
  186. <refsect2>
  187. <title>Memory handling</title>
  188. <para>neon does not attempt to cope gracefully with an
  189. out-of-memory situation; instead, by default, the
  190. <function>abort</function> function is called to immediately
  191. terminate the process. An application may register a custom
  192. function which will be called before <function>abort</function> in
  193. such a situation; see <xref linkend="ne_oom_callback"/>.</para>
  194. </refsect2>
  195. <refsect2>
  196. <title>Callbacks and userdata</title>
  197. <para>Whenever a callback is registered, a
  198. <literal>userdata</literal> pointer is also used to allow the
  199. application to associate a context with the callback. The
  200. userdata is of type <type>void *</type>, allowing any pointer to
  201. be used.</para>
  202. </refsect2>
  203. <refsect2>
  204. <title>Large File Support</title>
  205. <para>Since version 0.27.0, &neon; transparently uses the "LFS
  206. transitional" interfaces in functions which use file descriptors.
  207. This allows use of files larger than 2GiB on platforms with a
  208. native 32-bit <literal>off_t</literal> type, where LFS support is
  209. available.</para>
  210. <para>Some &neon; interfaces use the <literal>ne_off_t</literal>
  211. type, which is defined to be either <literal>off_t</literal> or
  212. <literal>off64_t</literal> according to whether LFS support is
  213. detected at build time. &neon; does not use or require the
  214. <literal>-D_FILE_OFFSET_BITS=64</literal> macro definition.</para>
  215. </refsect2>
  216. </refsect1>
  217. <refsect1>
  218. <title>See also</title>
  219. <para><xref linkend="refsess"/>, <xref linkend="ne_oom_callback"/>,
  220. <ulink url="https://notroj.github.io/neon/"/></para>
  221. </refsect1>
  222. </refentry>