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

Usage:http_serve_fetch(Stream,Serve)

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)).

    PREDICATEhttp_bind/1

    Usage:http_bind(Port)

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

      PREDICATEhttp_loop/1

      Usage:http_loop(ExitCode)

      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).

        Usage:http_shutdown(ExitCode)

        ExitCode mark that we are not going to process further requests

          Usage:http_protect(Handler,ErrHandler,Request,Response)

          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: