1NE_SESSION_CREATE(3) neon API reference NE_SESSION_CREATE(3)
2
3
4
6 ne_session_create, ne_close_connection, ne_session_destroy - set up
7 HTTP sessions
8
10 #include <ne_session.h>
11
12 ne_session *ne_session_create(const char *scheme, const char *hostname,
13 unsigned int port);
14
15 void ne_close_connection(ne_session *session);
16
17 void ne_session_destroy(ne_session *session);
18
20 An ne_session object represents an HTTP session - a logical grouping of
21 a sequence of HTTP requests made to a certain server. Any requests made
22 using the session can use a persistent connection, share cached
23 authentication credentials and any other common attributes.
24
25 A new HTTP session is created using the ne_session_create function; the
26 hostname and port parameters specify the origin server to use, along
27 with the scheme (usually "http"). Before the first use of
28 ne_session_create in a process, ne_sock_init must have been called to
29 perform any global initialization needed by any libraries used by neon.
30
31 To enable SSL/TLS for the session, pass the string "https" as the
32 scheme parameter, and either register a certificate verification
33 function (see ne_ssl_set_verify) or trust the appropriate certificate
34 (see ne_ssl_trust_cert, ne_ssl_trust_default_ca).
35
36 To use a proxy server for the session, it must be configured (see
37 ne_session_proxy) before any requests are created from session object.
38
39 Further per-session options may be changed using the
40 ne_set_session_flag interface.
41
42 If it is known that the session will not be used for a significant
43 period of time, ne_close_connection can be called to close the
44 connection, if one remains open. Use of this function is entirely
45 optional, but it must not be called if there is a request active using
46 the session.
47
48 Once a session has been completed, ne_session_destroy must be called to
49 destroy the resources associated with the session. Any subsequent use
50 of the session pointer produces undefined behaviour. The session object
51 must not be destroyed until after all associated request objects have
52 been destroyed.
53
55 The hostname passed to ne_session_create is resolved when the first
56 request using the session is dispatched; a DNS resolution failure can
57 only be detected at that time (using the NE_LOOKUP error code); see
58 ne_request_dispatch for details.
59
61 ne_session_create will return a pointer to a new session object (and
62 never NULL).
63
65 Create and destroy a session:
66
67 ne_session *sess;
68 sess = ne_session_create("http", "host.example.com", 80);
69 /* ... use sess ... */
70 ne_session_destroy(sess);
71
73 ne_ssl_set_verify, ne_ssl_trust_cert, ne_sock_init, ne_set_session_flag
74
76 Joe Orton <neon@lists.manyfish.co.uk>
77 Author.
78
80neon 0.30.0 31 July 2013 NE_SESSION_CREATE(3)