This directory provides the SWI-Prolog libraries for accessing and providing HTTP services.
The main client library is library(http/http_open), which can open
both HTTP and HTTPS connections and handle all request methods.
The main server libraries are
library(http/thread_httpd) implements the serverlibrary(http/http_dispatch) implements binding locations
predicateslibrary(http/http_unix_daemon) implements integration in various
Unix server managers and in general provides a suitable entry point
for HTTP servers on Unix.library(http/html_write) implements generating HTMLlibrary(http/http_json) implements reading and writing JSON documents.
For simplicity, you can use library(http/http_server), which
combines the typical HTTP libraries that most servers need. The
idea of a common request handling system and three controlling
libraries is outdated; the threaded server now being the only sensible
controlling library.
This library uses functionality from the ssl package to support HTTPS,
the sgml package to read XML/HTML and the clib package for various
extensions.
html_decl.pl![]() | ||
|---|---|---|
| html_meta/1 | This directive can be used to declare that an HTML rendering rule takes HTML content as argument. | ![]() |
| html_no_content/1 | True when Element has no content. | ![]() |
html_head.pl -- Automatic inclusion of CSS and scripts links![]() | ||
html_quasiquotations.pl -- HTML quasi quotations![]() | ||
html_write.pl![]() | ||
| html/3 | Generate HTML from Content. | ![]() |
| html_begin/3 | For html_begin//1, Env is a term Env(Attributes); for html_end//1 it is the plain environment name. | ![]() |
| html_current_option/1 | True if Option is an active option for the HTML generator. | ![]() |
| html_end/3 | For html_begin//1, Env is a term Env(Attributes); for html_end//1 it is the plain environment name. | ![]() |
| html_header_hook/1 | This multifile hook is called just before the Content-type header is emitted. | ![]() |
| html_post/4 | Reposition HTML to the receiving Id. | ![]() |
| html_quoted/3 | Quote the value for normal (CDATA) text. | ![]() |
| html_quoted_attribute/3 | Quote the value according to the rules for tag-attributes included in double-quotes. | ![]() |
| html_receive/3 | Receive posted HTML tokens. | ![]() |
| html_receive/4 | This extended version of html_receive//1 causes Handler to be called to process all messages posted to the channel at the time output is generated. | ![]() |
| html_root_attribute/4 | Add an attribute to the HTML root element of the page. | ![]() |
| html_set_options/1 | Set options for the HTML output. | ![]() |
| layout/3 | Define required newlines before and after tags. | ![]() |
| page/3 | Generate a page including the HTML <!DOCTYPE> header. | ![]() |
| page/4 | Generate a page including the HTML <!DOCTYPE> header. | ![]() |
| print_html/1 | Print list of atoms and layout instructions. | ![]() |
| print_html/2 | Print list of atoms and layout instructions. | ![]() |
| reply_html_page/2 | Provide the complete reply as required by http_wrapper.pl for a page constructed from Head and Body. | ![]() |
| reply_html_page/3 | Provide the complete reply as required by http_wrapper.pl for a page constructed from Head and Body. | ![]() |
| reply_html_partial/1 | Reply with partial HTML document. | ![]() |
| xhtml_ns/4 | Demand an xmlns:id=Value in the outer html tag. | ![]() |
http_client.pl![]() | ||
| post_data_hook/3 | Hook to extend the datatypes supported by the post(Data) option of http_open/3. | ![]() |
| http_convert_data/4 | Multi-file hook to convert a HTTP payload according to the Content-Type header. | ![]() |
| http_delete/3 | Execute a DELETE method on the server. | ![]() |
| http_disconnect/1 | Close down some connections. | ![]() |
| http_get/3 | Get data from a URL server and convert it to a suitable Prolog representation based on the Content-Type header and plugins. | ![]() |
| http_patch/4 | Issue an HTTP PATCH request. | ![]() |
| http_post/4 | Issue an HTTP POST request. | ![]() |
| http_put/4 | Issue an HTTP PUT request. | ![]() |
| http_read_data/3 | Read data from an HTTP connection and convert it according to the supplied to(Format) option or based on the Content-type in the Request. | ![]() |
http_cors.pl![]() | ||
| cors_enable/0 | Emit the HTTP header Access-Control-Allow-Origin using domains from the setting http:cors. | ![]() |
| cors_enable/2 | CORS reply to a Preflight OPTIONS request. | ![]() |
http_dispatch.pl -- Dispatch requests in the HTTP server![]() | ||
http_dyn_workers.pl -- Dynamically schedule HTTP workers.![]() | ||
http_exception.pl![]() | ||
| bad_request_error/2 | If an exception of the term error(Formal, context(Stack, Context)) is caught and subsumes_term(ContextTemplate, Context) is true, translate the exception into an HTTP 400 exception. | |
| in_or_exclude_backtrace/2 | Remove the stacktrace from the exception, unless setting http:client_backtrace is true. | ![]() |
| map_exception_to_http_status/4 | Map certain exceptions to HTTP status codes. | ![]() |
http_header.pl![]() | ||
| http_address/2 | HTML-rule that emits the location of the HTTP server. | |
| mime_type_encoding/2 | Encoding is the (default) character encoding for MimeType. | |
| serialize_reply/2 | Multifile hook to serialize the result of status_reply/3 into a term. | ![]() |
| status_page/3 | Hook called by http_status_reply/4 and http_status_reply/5 that allows for emitting custom error pages for the following HTTP page types:. | |
| http_join_headers/3 | Append headers from Default to Header if they are not already part of it. | ![]() |
| http_parse_header/2 | Header is a list of Name(Value)-terms representing the structure of the HTTP header in Text. | ![]() |
| http_parse_header_value/3 | Translate Value in a meaningful Prolog term. | ![]() |
| http_post_data/3 | Send data on behalf on an HTTP POST request. | ![]() |
| http_read_header/2 | Read Name: Value lines from FD until an empty line is encountered. | ![]() |
| http_read_reply_header/2 | Read the HTTP reply header. | ![]() |
| http_read_request/2 | Read an HTTP request-header from FdIn and return the broken-down request fields as +Name(+Value) pairs in a list. | ![]() |
| http_reply/2 | Compose a complete HTTP reply from the term Data using additional headers from HdrExtra to the output stream Out. | ![]() |
| http_reply/3 | Compose a complete HTTP reply from the term Data using additional headers from HdrExtra to the output stream Out. | ![]() |
| http_reply/4 | Compose a complete HTTP reply from the term Data using additional headers from HdrExtra to the output stream Out. | ![]() |
| http_reply/5 | Compose a complete HTTP reply from the term Data using additional headers from HdrExtra to the output stream Out. | ![]() |
| http_reply/6 | Compose a complete HTTP reply from the term Data using additional headers from HdrExtra to the output stream Out. | ![]() |
| http_reply_header/3 | Create a reply header using reply_header//3 and send it to Stream. | ![]() |
| http_status_reply/4 | Emit HTML non-200 status reports. | ![]() |
| http_status_reply/5 | Emit HTML non-200 status reports. | ![]() |
| http_timestamp/2 | Convert between a SWI-Prolog time stamp and a string in HTTP format (RFC1123). | ![]() |
| http_update_connection/4 | Merge keep-alive information from Request and CGIHeader into Header. | ![]() |
| http_update_encoding/3 | Allow for rewrite of the header, adjusting the encoding. | ![]() |
| http_update_transfer/4 | Decide on the transfer encoding from the Request and the CGI header. | ![]() |
http_hook.pl -- HTTP library hooks![]() | ||
http_host.pl![]() | ||
| http_current_host/4 | ![]() | |
| http_public_host/4 | Current global host and port of the HTTP server. | ![]() |
| http_public_host_url/2 | True when URL is the public URL at which this server can be contacted. | ![]() |
| http_public_url/2 | True when URL is an absolute URL for the current request. | ![]() |
http_log.pl![]() | ||
| http_log/2 | Write message from Format and Args to log-stream. | ![]() |
| http_log_close/1 | If there is a currently open HTTP logfile, close it after adding a term server(Reason, Time). | ![]() |
| http_log_stream/1 | True when Stream is a stream to the opened HTTP log file. | ![]() |
| http_logrotate/1 | Rotate the available log files. | ![]() |
| http_schedule_logrotate/2 | Schedule log rotation based on maintenance broadcasts. | ![]() |
| nolog/1 | Multifile predicate that can be defined to hide request parameters from the request logfile. | ![]() |
| password_field/1 | Multifile predicate that can be defined to hide passwords from the logfile. | ![]() |
| post_data_encoded/2 | Encode the POST body for inclusion into the HTTP log file. | ![]() |
http_multipart_plugin.pl -- Multipart form-data plugin![]() | ||
http_open.pl -- HTTP client library![]() | ||
http_parameters.pl![]() | ||
| http_convert_parameter/4 | Conversion of an HTTP form value. | ![]() |
| http_convert_parameters/2 | Implements the parameter translation of http_parameters/2 or http_parameters/3. | ![]() |
| http_convert_parameters/3 | Implements the parameter translation of http_parameters/2 or http_parameters/3. | ![]() |
| http_parameters/2 | Get HTTP GET or POST form-data, applying type validation, default values, etc. | ![]() |
| http_parameters/3 | Get HTTP GET or POST form-data, applying type validation, default values, etc. | ![]() |
http_path.pl -- Abstract specification of HTTP server locations![]() | ||
http_redis_plugin.pl -- Hook session management to use Redis![]() | ||
http_server.pl -- HTTP server library![]() | ||
http_server_files.pl -- Serve files needed by modules from the server![]() | ||
http_server_health.pl -- HTTP Server health statistics![]() | ||
http_session.pl -- HTTP Session management![]() | ||
http_stream.pl![]() | ||
| current_transfer_encoding/1 | True if Encoding is supported. | ![]() |
| encoding_filter/3 | Install a filter to deal with chunked encoded messages. | ![]() |
| cgi_discard/1 | Discard content produced so far. | ![]() |
| cgi_open/4 | Process CGI output. | ![]() |
| cgi_property/2 | Inquire the status of the CGI stream. | ![]() |
| cgi_set/2 | Change one of the properties. | ![]() |
| cgi_statistics/1 | Return statistics on the CGI stream subsystem. | ![]() |
| http_chunked_add_trailer/3 | Add a trailer key/value to DataStream. | ![]() |
| http_chunked_flush/2 | Emits the next chunk flush_output/1 on DataStream, but in addition adds extension parameters to the chunk. | ![]() |
| http_chunked_open/3 | Create a stream to realise HTTP chunked encoding or decoding. | ![]() |
| http_is_chunked/1 | True if DataStream is created using http_chunked_open/3. | ![]() |
| is_cgi_stream/1 | True if Stream is a CGI stream created using cgi_open/4. | ![]() |
| multipart_open/3 | DataStream is a stream that signals end_of_file if the multipart boundary is encountered. | ![]() |
| multipart_open_next/1 | Prepare DataStream to read the next part from the multipart input data. | ![]() |
| stream_range_open/3 | DataStream is a stream whose size is defined by the option size(ContentLength). | ![]() |
http_unix_daemon.pl![]() | ||
| sni_options/2 | Hook to provide Server Name Indication (SNI) for TLS servers. | |
| http_certificate_hook/3 | Hook called before starting the server if the --https option is used. | ![]() |
| http_daemon/0 | Start the HTTP server as a daemon process. | ![]() |
| http_daemon/1 | Start the HTTP server as a daemon process. | ![]() |
| http_opt_help/2 | Allow reusing http option processing. | ![]() |
| http_opt_meta/2 | Allow reusing http option processing. | ![]() |
| http_opt_type/3 | Allow reusing http option processing. | ![]() |
| http_server_hook/1 | Hook that is called to start the HTTP server. | ![]() |
http_wrapper.pl![]() | ||
| cgi_hook/2 | Hook called from the CGI processing stream. | ![]() |
| http_current_request/1 | Returns the HTTP request currently being processed. | ![]() |
| http_peer/2 | True when PeerIP is the IP address of the connection peer. | ![]() |
| http_relative_path/2 | Convert an absolute path (without host, fragment or search) into a path relative to the current page. | ![]() |
| http_send_header/1 | This API provides an alternative for writing the header field as a CGI header. | ![]() |
| http_spawned/1 | Internal use only. | ![]() |
| http_wrap_spawned/3 | Internal use only. | ![]() |
hub.pl![]() | ||
| current_hub/2 | True when there exists a hub Hub with Name. | ![]() |
| hub_add/3 | Add a WebSocket to the hub. | ![]() |
| hub_broadcast/2 | Send Message to all websockets associated with Hub for which call(Condition, Id) succeeds. | ![]() |
| hub_broadcast/3 | Send Message to all websockets associated with Hub for which call(Condition, Id) succeeds. | ![]() |
| hub_create/3 | Create a new hub. | ![]() |
| hub_member/2 | True when Id is a member of the hub HubName. | ![]() |
| hub_send/2 | Send message to the indicated ClientId. | ![]() |
js_write.pl -- Utilities for including JavaScript![]() | ||
mimepack.pl -- Create a MIME message![]() | ||
| mime_pack/3 | Pack a number of inputs into a MIME package using a specified or generated boundary. | ![]() |
mimetype.pl -- Determine mime-type for a file![]() | ||
term_html.pl -- Represent Prolog terms as HTML![]() | ||
thread_httpd.pl![]() | ||
| schedule_workers/1 | Hook called if a new connection or a keep-alive connection cannot be scheduled immediately to a worker. | ![]() |
| http_add_worker/2 | Add a new worker to the HTTP server for port Port. | ![]() |
| http_close_connection/1 | Close connection associated to Request. | ![]() |
| http_current_server/2 | True if Goal is the goal of a server at Port. | ![]() |
| http_current_worker/2 | True if ThreadID is the identifier of a Prolog thread serving Port. | ![]() |
| http_enough_workers/3 | Check that we have enough workers in our queue. | ![]() |
| http_requeue/1 | Re-queue a connection to the worker pool. | ![]() |
| http_server/2 | Create a server at Port that calls Goal for each parsed request. | ![]() |
| http_server_property/2 | True if Property is a property of the HTTP server running at Port. | ![]() |
| http_spawn/2 | Continue this connection on a new thread. | ![]() |
| http_stop_server/2 | Stop the indicated HTTP server gracefully. | ![]() |
| http_workers/2 | Query or set the number of workers for the server at this port. | ![]() |
| message_level/2 | Determine the message stream used for exceptions that may occur during server_loop/5. | ![]() |
websocket.pl -- WebSocket support![]() | ||