ne_session_create.3 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. '\" t
  2. .\" Title: ne_session_create
  3. .\" Author:
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 21 January 2023
  6. .\" Manual: neon API reference
  7. .\" Source: neon 0.32.5
  8. .\" Language: English
  9. .\"
  10. .TH "NE_SESSION_CREATE" "3" "21 January 2023" "neon 0.32.5" "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\ *" "hostname" ", 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. \fIhostname\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
  70. parameter, and either register a certificate verification function (see
  71. ne_ssl_set_verify) or trust the appropriate certificate (see
  72. ne_ssl_trust_cert,
  73. ne_ssl_trust_default_ca)\&.
  74. .PP
  75. To use a proxy server for the session, it must be configured (see
  76. ne_session_proxy) before any requests are created from session object\&.
  77. .PP
  78. Further per\-session options may be changed using the
  79. ne_set_session_flag
  80. interface\&.
  81. .PP
  82. If it is known that the session will not be used for a significant period of time,
  83. \fBne_close_connection\fR
  84. 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\&.
  85. .PP
  86. Once a session has been completed,
  87. \fBne_session_destroy\fR
  88. 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\&.
  89. .SH "NOTES"
  90. .PP
  91. The hostname passed to
  92. \fBne_session_create\fR
  93. is resolved when the first request using the session is dispatched; a DNS resolution failure can only be detected at that time (using the
  94. NE_LOOKUP
  95. error code); see
  96. ne_request_dispatch
  97. for details\&.
  98. .SH "RETURN VALUES"
  99. .PP
  100. \fBne_session_create\fR
  101. will return a pointer to a new session object (and never
  102. NULL)\&.
  103. .SH "EXAMPLES"
  104. .PP
  105. Create and destroy a session:
  106. .sp
  107. .if n \{\
  108. .RS 4
  109. .\}
  110. .nf
  111. ne_session *sess;
  112. sess = ne_session_create("http", "host\&.example\&.com", 80);
  113. /* \&.\&.\&. use sess \&.\&.\&. */
  114. ne_session_destroy(sess);
  115. .fi
  116. .if n \{\
  117. .RE
  118. .\}
  119. .SH "SEE ALSO"
  120. .PP
  121. ne_ssl_set_verify,
  122. ne_ssl_trust_cert,
  123. ne_sock_init,
  124. ne_set_session_flag
  125. .SH "AUTHOR"
  126. .PP
  127. \fBJoe Orton\fR
  128. .RS 4
  129. Author.
  130. .RE
  131. .SH "COPYRIGHT"
  132. .br