primitives for parsing and composing HTTP headers. Its functionality is
normally hidden by the other parts of the HTTP server and client
libraries. We provide a brief overview of http_reply/3
which can be accessed from the reply body using an exception as explain
in section 3.1.1.
- http_reply(+Type, +Stream, +HdrExtra)
- Compose a complete HTTP reply from the term Type using
additional headers from HdrExtra to the output stream Stream.
ExtraHeader is a list of
Field(Value). Type is one of:
- Produce a HTML page using print_html/1,
normally generated using the
library(http/html_write)described in section 3.18.
- file(+MimeType, +Path)
- Reply the content of the given file, indicating the given MIME type.
- tmp_file(+MimeType, +Path)
- Similar to
File(+MimeType, +Path), but do not include a modification time header.
- stream(+Stream, +Len)
- Reply using the next Len characters from Stream. The user must provides the MIME type and other attributes through the ExtraHeader argument.
- cgi_stream(+Stream, +Len)
- Similar to
stream(+Stream, +Len), but the data on Stream must contain an HTTP header.
- Generate a ``301 Moved Permanently'' page with the given target URL.
- Generate a ``302 Moved Temporary'' page with the given target URL.
- Generate a ``303 See Other'' page with the given target URL.
- Generate a ``404 Not Found'' page.
- Generate a ``403 Forbidden'' page, denying access without challenging the client.
- authorise(+Method, +Realm)
- Generate a ``401 Authorization Required'', requesting the client to retry using proper credentials (i.e. user and password).
- Generate a ``304 Not Modified'' page, indicating the requested resource has not changed since the indicated time.
- Generate a ``500 Internal server error'' page with a message generated from a Prolog exception term (see print_message/2).