<h1>libsoup Bindings</h1>

<h2>Synopsis</h2>

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

Basic bindings to the HTTP library.

<h2>Client Operations</h2>

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

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
<h3>procedure: <code>(soup-server <i>proc</i>
<h3>procedure: <code>(soup-server <i>proc</i> <i>host</i>

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

Retrieves the listening port of the given server.

<h3>procedure: <code>(soup-server-close

Disconnects the server from the network.

<h2>Request Environment</h2>

<h3>parameter:

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

<h3>parameter:

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

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

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

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

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

<h3>procedure:
<h3>procedure: <code>(open-request-body-output-port

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:
<h3>procedure: <code>(open-response-body-output-port

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:
<h3>procedure: <code>(open-request-body-input-port

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:
<h3>procedure: <code>(open-response-body-input-port

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.