HTTP server

Author(s): The Ciao Development Team, Jose F. Morales (multifile-based HTTP simple server).

This module implements a simple HTTP server.

It can be used to handle individual HTTP requests (http_serve_fetch/2) or for implementing a simple HTTP server (see http_bind/1, http_loop/1, http_shutdown/1).

Clients of this module must use the http_server_hooks package and implement the multifile httpserv.handle/3 (see http_loop/1 for details).

Usage and interface

Documentation on exports


Read a HTTP request from Stream, obtain the response calling Serve predicate, and write the response to the socket stream.

    Meta-predicate with arguments: http_serve_fetch(?,pred(2)).



    Bind socket to the port Port (use with http_loop/1)



      Listen and handle HTTP requests in a loop. You can terminate this loop by http_shutdown/1 predicate. Requests are handled by multifile httpserv.handle/3 and httpserv.file_path/2 predicates (declared in http_server_hooks file).


        ExitCode mark that we are not going to process further requests


          Execute Handler on Request to obtain Response. If Handler fails or raises some exception E, a response is obtained calling ErrHandler on E. This is useful, for example, to produce an HTML page informing about the incident

            Meta-predicate with arguments: http_protect(pred(2),pred(2),?,?).

            Documentation on multifiles

            No further documentation available for this predicate. The predicate is multifile.

            No further documentation available for this predicate. The predicate is multifile.

            Documentation on imports

            This module has the following direct dependencies: