Files
2026-08-07 17:38:18 +09:00

36 lines
6.4 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_session_create</title><link rel="stylesheet" href="../manual.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="prev" href="refalloc.html" title="ne_malloc"><link rel="next" href="refreq.html" title="ne_request_create"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ne_session_create</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refalloc.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="refreq.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="refsess"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_session_create, ne_close_connection, ne_session_proxy, ne_session_destroy — set up HTTP sessions</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;ne_session.h&gt;</pre><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">ne_session *<b class="fsfunc">ne_session_create</b>(</code>const char *<var xmlns="" class="pdparam">scheme</var>, const char *<var xmlns="" class="pdparam">hostname</var>, unsigned int <var xmlns="" class="pdparam">port</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">void <b class="fsfunc">ne_session_proxy</b>(</code>ne_session *<var xmlns="" class="pdparam">session</var>, const char *<var xmlns="" class="pdparam">hostname</var>, unsigned int <var xmlns="" class="pdparam">port</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">void <b class="fsfunc">ne_close_connection</b>(</code>ne_session *<var xmlns="" class="pdparam">session</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">void <b class="fsfunc">ne_session_destroy</b>(</code>ne_session *<var xmlns="" class="pdparam">session</var><code xmlns="">)</code>;</code></div></div></div><div class="refsect1" lang="en"><a name="id2935438"></a><h2>Description</h2><p>An <em class="type">ne_session</em> 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.</p><p>A new HTTP session is created using
<code class="function">ne_session_create</code>, giving the
<code class="parameter">hostname</code> and <code class="parameter">port</code> of the
server to use, along with the <code class="parameter">scheme</code> used to
contact the server (usually <code class="literal">"http"</code>). Before the
first use of <code class="function">ne_session_create</code> in a process,
<a href="refsockinit.html#ne_sock_init">ne_sock_init</a> must have been called to perform any
global initialization needed by any libraries used by neon.</p><p>To enable SSL/TLS for the session, pass the string
<code class="literal">"https"</code> as the <code class="parameter">scheme</code>
parameter, and either register a certificate verification function
(see <a href="refsslvfy.html#ne_ssl_set_verify">ne_ssl_set_verify</a>) or trust the appropriate
certificate (see <a href="refsslca.html#ne_ssl_trust_cert">ne_ssl_trust_cert</a>, <a href="refsslca.html#ne_ssl_trust_default_ca">ne_ssl_trust_default_ca</a>).</p><p>If an HTTP proxy server should be used for the session,
<code class="function">ne_session_proxy</code> must be called giving the
hostname and port on which to contact the proxy.</p><p>If it is known that the session will not be used for a
significant period of time, <code class="function">ne_close_connection</code>
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.</p><p>Once a session has been completed,
<code class="function">ne_session_destroy</code> must be called to destroy the
resources associated with the session. Any subsequent use of the
session pointer produces undefined behaviour.</p></div><div class="refsect1" lang="en"><a name="id2935580"></a><h2>Notes</h2><p>The hostname passed to
<code class="function">ne_session_create</code> is resolved when the first
request using the session is dispatched; a DNS resolution failure can
only be detected at that time (using the <code class="literal">NE_LOOKUP</code>
error code); see <a href="refreq.html#ne_request_dispatch">ne_request_dispatch</a> for
details.</p></div><div class="refsect1" lang="en"><a name="id2935611"></a><h2>Return Values</h2><p><code class="function">ne_session_create</code> will return
a pointer to a new session object (and never <code class="literal">NULL</code>).</p></div><div class="refsect1" lang="en"><a name="id2935633"></a><h2>Examples</h2><p>Create and destroy a session:</p><pre class="programlisting">ne_session *sess;
sess = ne_session_create("http", "host.example.com", 80);
/* ... use sess ... */
ne_session_destroy(sess);
</pre></div><div class="refsect1" lang="en"><a name="id2935651"></a><h2>See Also</h2><p><a href="refsslvfy.html#ne_ssl_set_verify">ne_ssl_set_verify</a>, <a href="refsslca.html#ne_ssl_trust_cert">ne_ssl_trust_cert</a>, <a href="refsockinit.html#ne_sock_init">ne_sock_init</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refalloc.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="refreq.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ne_malloc </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_request_create</td></tr></table></div></body></html>