chez-libs

Artifact [bbd93158c2]
Login

Artifact bbd93158c2988d83bbbde5ef14d8b118c5294f3c:

Wiki page [(network soup)] by murphy 2016-05-26 15:05:13.
D 2016-05-26T15:05:13.852
L (network\ssoup)
P 54b158eecf1ca2df31c75eb5919194d076913637
U murphy
W 4456
<h1>libsoup Bindings</h1>

<h2>Synopsis</h2>

<code>(import (network soup))</code>

Basic bindings to the [https://wiki.gnome.org/Projects/libsoup|libsoup] HTTP library.

<h2>Client Operations</h2>

<h3>procedure: <code>((soup-client) <i>method</i> <i>uri</i> <i>proc-response</i>)</code></h3>
<h3>procedure: <code>((soup-client) <i>method</i> <i>uri</i> <i>proc-request</i> <i>proc-response</i>)</code></h3>

Creates a new client request procedure. When called, a new soup message is set up using the request procedure, if any. The message is then dispatched asynchronously and the response can be processed in the second callback procedure. Either callback may be <tt>#f</tt>.

Both callbacks are applied to the method and URI within a dynamic environment that allows access to the request or response body and headers.

<h2>Server Operations</h2>

<h3>procedure: <code>(soup-server <i>proc</i>)</code></h3>
<h3>procedure: <code>(soup-server <i>proc</i> <i>port</i>)</code></h3>
<h3>procedure: <code>(soup-server <i>proc</i> <i>host</i> <i>port</i>)</code></h3>

Creates a new server object. The given procedure will be invoked with the request method and URI of each request. If no host is specified, the server will listen only to local requests. If no port is specified, the server will listen on a random port.

The server is started asynchronously and will run in the GLib main loop.

<h3>procedure: <code>(soup-server-port <i>srv</i>)</code></h3>

Retrieves the listening port of the given server.

<h3>procedure: <code>(soup-server-close <i>srv</i>)</code></h3>

Disconnects the server from the network.

<h2>Request Environment</h2>

<h3>parameter: <code>current-soup-client</code></h3>

Holds the host address of the client that issued the current request.

<h3>parameter: <code>current-soup-message</code></h3>

Holds a reference to the SoupMessage object for the current request.

<h3>procedure: <code>(request-header <i>name</i>)</code></h3>
<h3>procedure: <code>(request-header <i>name</i> <i>value</i>)</code></h3>

Retrieves the request header with the given name or adds a new header with that name.

<h3>procedure: <code>(response-header <i>name</i>)</code></h3>
<h3>procedure: <code>(response-header <i>name</i> <i>value</i>)</code></h3>

Retrieves the response header with the given name or adds a new header with that name.

<h3>procedure: <code>(open-request-body-output-port)</code></h3>
<h3>procedure: <code>(open-request-body-output-port <i>transcoder</i>)</code></h3>

Opens an output port to write to the request body. If no transcoder or <tt>#f</tt> is given, the result is a binary output port. If a transcoder or <tt>#t</tt> is passed, the result is a textual output port. If the transcoder argument is <tt>#t</tt>, the codec for the port is guessed from the charset parameter in the request's <tt>Content-Type</tt> header.

<h3>procedure: <code>(open-response-body-output-port)</code></h3>
<h3>procedure: <code>(open-response-body-output-port <i>transcoder</i>)</code></h3>

Opens an output port to write to the response body. If no transcoder or <tt>#f</tt> is given, the result is a binary output port. If a transcoder or <tt>#t</tt> is passed, the result is a textual output port. If the transcoder argument is <tt>#t</tt>, the codec for the port is guessed from the charset parameter in the response's <tt>Content-Type</tt> header.

<h3>procedure: <code>(open-request-body-input-port)</code></h3>
<h3>procedure: <code>(open-request-body-input-port <i>transcoder</i>)</code></h3>

Opens an input port to read from the request body. If no transcoder or <tt>#f</tt> is given, the result is a binary input port. If a transcoder or <tt>#t</tt> is passed, the result is a textual input port. If the transcoder argument is <tt>#t</tt>, the codec for the port is guessed from the charset parameter in the request's <tt>Content-Type</tt> header.

<h3>procedure: <code>(open-response-body-input-port)</code></h3>
<h3>procedure: <code>(open-response-body-input-port <i>transcoder</i>)</code></h3>

Opens an input port to read from the response body. If no transcoder or <tt>#f</tt> is given, the result is a binary input port. If a transcoder or <tt>#t</tt> is passed, the result is a textual input port. If the transcoder argument is <tt>#t</tt>, the codec for the port is guessed from the charset parameter in the response's <tt>Content-Type</tt> header.

Z 9ff5cb2730513a64a24c53c75f56a024