opts.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <refentry id="refopts">
  2. <refmeta>
  3. <refentrytitle>ne_set_useragent</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_set_useragent">ne_set_useragent</refname>
  8. <refname id="ne_set_read_timeout">ne_set_read_timeout</refname>
  9. <refname id="ne_set_connect_timeout">ne_set_connect_timeout</refname>
  10. <refname id="ne_get_scheme">ne_get_scheme</refname>
  11. <refname id="ne_get_server_hostport">ne_get_server_hostport</refname>
  12. <refpurpose>common properties for HTTP sessions</refpurpose>
  13. </refnamediv>
  14. <refsynopsisdiv>
  15. <funcsynopsis>
  16. <funcsynopsisinfo>#include &lt;ne_session.h&gt;</funcsynopsisinfo>
  17. <funcprototype>
  18. <funcdef>void <function>ne_set_useragent</function></funcdef>
  19. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  20. <paramdef>const char *<parameter>product</parameter></paramdef>
  21. </funcprototype>
  22. <funcprototype>
  23. <funcdef>void <function>ne_set_read_timeout</function></funcdef>
  24. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  25. <paramdef>int <parameter>timeout</parameter></paramdef>
  26. </funcprototype>
  27. <funcprototype>
  28. <funcdef>void <function>ne_set_connect_timeout</function></funcdef>
  29. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  30. <paramdef>int <parameter>timeout</parameter></paramdef>
  31. </funcprototype>
  32. <funcprototype>
  33. <funcdef>const char *<function>ne_get_scheme</function></funcdef>
  34. <paramdef>ne_sesssion *<parameter>session</parameter></paramdef>
  35. </funcprototype>
  36. <funcprototype>
  37. <funcdef>const char *<function>ne_get_server_hostport</function></funcdef>
  38. <paramdef>ne_sesssion *<parameter>session</parameter></paramdef>
  39. </funcprototype>
  40. </funcsynopsis>
  41. </refsynopsisdiv>
  42. <refsect1>
  43. <title>Description</title>
  44. <para>The <literal>User-Agent</literal> request header is used
  45. to identify the software which generated the request for statistical
  46. or debugging purposes. neon does not send a
  47. <literal>User-Agent</literal> header unless a call is made to the
  48. <function>ne_set_useragent</function>.
  49. <function>ne_set_useragent</function> must be passed a product string
  50. conforming to RFC2616's product token grammar; of the form
  51. <literal>"Product/Version"</literal>.</para>
  52. <para>When neon reads from a socket, by default the read
  53. operation will time out after 60 seconds, and the request will fail
  54. giving an <errorcode>NE_TIMEOUT</errorcode> error. To configure this
  55. timeout interval, call <function>ne_set_read_timeout</function> giving
  56. the desired number of seconds as the <parameter>timeout</parameter>
  57. parameter.</para>
  58. <para>When a connection is being established to a server,
  59. normally only the system's TCP timeout handling will apply.
  60. To configure a specific (and probably shorter) timeout, the
  61. <function>ne_set_connect_timeout</function> can be used,
  62. giving the desired number of seconds as the
  63. <parameter>timeout</parameter> parameter. If
  64. <literal>0</literal> is passed, then the default behaviour of
  65. using the system TCP timeout will be used.</para>
  66. <para>The scheme used to initially create the session will be
  67. returned by <function>ne_get_scheme</function>.</para>
  68. <para>The hostport pair with which the session is associated
  69. will be returned by the
  70. <function>ne_get_server_hostport</function>; for example
  71. <literal>www.example.com:8080</literal>. Note that the
  72. <literal>:port</literal> will be omitted if the default port
  73. for the scheme is used.</para>
  74. </refsect1>
  75. <refsect1>
  76. <title>Examples</title>
  77. <para>Set a user-agent string:</para>
  78. <programlisting>&egsess;
  79. ne_set_useragent(sess, "MyApplication/2.1");</programlisting>
  80. <para>Set a 30 second read timeout:</para>
  81. <programlisting>&egsess;
  82. ne_set_read_timeout(sess, 30);</programlisting>
  83. </refsect1>
  84. <refsect1>
  85. <title>See also</title>
  86. <para><xref linkend="ne_session_create"/>, <xref
  87. linkend="ne_set_session_flag"/>.</para>
  88. </refsect1>
  89. </refentry>