ne_session_create.3 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. '\" t
  2. .\" Title: ne_session_create
  3. .\" Author:
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 15 July 2025
  6. .\" Manual: neon API reference
  7. .\" Source: neon 0.35.0
  8. .\" Language: English
  9. .\"
  10. .TH "NE_SESSION_CREATE" "3" "15 July 2025" "neon 0.35.0" "neon API reference"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. ne_session_create, ne_close_connection, ne_session_destroy \- set up HTTP sessions
  32. .SH "SYNOPSIS"
  33. .sp
  34. .ft B
  35. .nf
  36. #include <ne_session\&.h>
  37. .fi
  38. .ft
  39. .HP \w'ne_session\ *ne_session_create('u
  40. .BI "ne_session *ne_session_create(const\ char\ *" "scheme" ", const\ char\ *" "host" ", unsigned\ int\ " "port" ");"
  41. .HP \w'void\ ne_close_connection('u
  42. .BI "void ne_close_connection(ne_session\ *" "session" ");"
  43. .HP \w'void\ ne_session_destroy('u
  44. .BI "void ne_session_destroy(ne_session\ *" "session" ");"
  45. .SH "DESCRIPTION"
  46. .PP
  47. An
  48. \fBne_session\fR
  49. object represents an HTTP session \- a logical grouping of a sequence of HTTP requests made to a certain server\&. Any requests made using the session can use a persistent connection, share cached authentication credentials and any other common attributes\&.
  50. .PP
  51. A new HTTP session is created using the
  52. \fBne_session_create\fR
  53. function; the
  54. \fIhost\fR
  55. and
  56. \fIport\fR
  57. parameters specify the origin server to use, along with the
  58. \fIscheme\fR
  59. (usually
  60. "http")\&. Before the first use of
  61. \fBne_session_create\fR
  62. in a process,
  63. ne_sock_init
  64. must have been called to perform any global initialization needed by any libraries used by neon\&.
  65. .PP
  66. To enable SSL/TLS for the session, pass the string
  67. "https"
  68. as the
  69. \fIscheme\fR, and either register a certificate verification function (see
  70. ne_ssl_set_verify) or trust the appropriate certificate (see
  71. ne_ssl_trust_cert,
  72. ne_ssl_trust_default_ca)\&.
  73. .PP
  74. The
  75. \fIhost\fR
  76. parameter must follow the definition of host
  77. host
  78. in
  79. \m[blue]\fBRFC 3986\fR\m[]\&\s-2\u[1]\d\s+2, which can be an IP\-literal or registered (DNS) hostname\&. Valid examples of each:
  80. "198\&.51\&.100\&.42"
  81. (IPv4 literal address),
  82. "[2001:db8::42]"
  83. (IPv6 literal, which
  84. \fIMUST\fR
  85. be enclosed in square brackets), or
  86. "www\&.example\&.com"
  87. (DNS hostname)\&. The
  88. \m[blue]\fBRFC 6874\fR\m[]\&\s-2\u[2]\d\s+2
  89. syntax for scoped IPv6 link\-local literal addresses is also permitted, for example
  90. "[fe80::1%25eth0]"\&.
  91. .PP
  92. The
  93. \fIscheme\fR
  94. parameter is used to determine the URI for resources identified during request handling\&. Other than special handling of the string
  95. "https", no other interpretation or checking of the
  96. \fIscheme\fR
  97. is performed\&. For example, if an HTTP\-to\-FTP proxy is configured, a scheme of
  98. "ftp"
  99. could be used to access resources\&.
  100. .PP
  101. To use a proxy server for the session, it must be configured (see
  102. ne_session_proxy) before any requests are created from session object\&.
  103. .PP
  104. Further per\-session options may be changed using the
  105. ne_set_session_flag
  106. interface\&.
  107. .PP
  108. If it is known that the session will not be used for a significant period of time,
  109. \fBne_close_connection\fR
  110. can be called to close the connection, if one remains open\&. Use of this function is entirely optional, but it must not be called if there is a request active using the session\&.
  111. .PP
  112. Once a session has been completed,
  113. \fBne_session_destroy\fR
  114. must be called to destroy the resources associated with the session\&. Any subsequent use of the session pointer produces undefined behaviour\&. The session object must not be destroyed until after all associated request objects have been destroyed\&.
  115. .SH "NOTES"
  116. .PP
  117. If a hostname is passed to
  118. \fBne_session_create\fR, it will be resolved when the first request using the session is dispatched; a DNS resolution failure can only be detected at that time (using the
  119. NE_LOOKUP
  120. error code); see
  121. ne_request_dispatch
  122. for details\&.
  123. .SH "RETURN VALUES"
  124. .PP
  125. \fBne_session_create\fR
  126. will return a pointer to a new session object (and never
  127. NULL)\&.
  128. .SH "EXAMPLES"
  129. .PP
  130. Create and destroy a session:
  131. .sp
  132. .if n \{\
  133. .RS 4
  134. .\}
  135. .nf
  136. ne_session *sess;
  137. sess = ne_session_create("http", "host\&.example\&.com", 80);
  138. /* \&.\&.\&. use sess \&.\&.\&. */
  139. ne_session_destroy(sess);
  140. .fi
  141. .if n \{\
  142. .RE
  143. .\}
  144. .SH "SEE ALSO"
  145. .PP
  146. ne_ssl_set_verify,
  147. ne_ssl_trust_cert,
  148. ne_sock_init,
  149. ne_set_session_flag,
  150. ne_session_proxy
  151. .SH "COPYRIGHT"
  152. .br
  153. Copyright \(co 2001-2025 Joe Orton
  154. .br
  155. .SH "REFERENCES"
  156. .IP " 1." 4
  157. RFC 3986
  158. .RS 4
  159. \%https://www.rfc-editor.org/rfc/rfc3986
  160. .RE
  161. .IP " 2." 4
  162. RFC 6874
  163. .RS 4
  164. \%https://www.rfc-editor.org/rfc/rfc6874
  165. .RE