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 libraris 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_head.pl -- Automatic inclusion of CSS and scripts links![]() | ||
---|---|---|
html_quasiquotations.pl -- HTML quasi quotations![]() | ||
html/4 | The predicate html/4 implements HTML quasi quotations. | ![]() |
html_write.pl -- Write HTML text![]() | ||
http_client.pl -- HTTP client library![]() | ||
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 -- Enable CORS: Cross-Origin Resource Sharing![]() | ||
http_dirindex.pl -- HTTP directory listings![]() | ||
http_dispatch.pl -- Dispatch requests in the HTTP server![]() | ||
http_dyn_workers.pl -- Dynamically schedule HTTP workers.![]() | ||
http_exception.pl -- Map Prolog exceptions to HTTP errors![]() | ||
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_files.pl -- Serve plain files from a hierarchy![]() | ||
http_header.pl -- Handling HTTP headers![]() | ||
http_hook.pl -- HTTP library hooks![]() | ||
convert_parameter/3 | Hook to execute a step in the HTTP parameter conversion process. | |
http_connection_over_proxy/6 | Try to connect to the host Endpoint via Proxy for the purposes of retrieving the resource identified by URLParts. | ![]() |
http_host.pl -- Obtain public server location![]() | ||
http_json.pl -- HTTP JSON Plugin module![]() | ||
post_data_hook/3 | Hook implementation that allows http_post_data/3 posting JSON objects using one of the forms below. | ![]() |
http_convert_data/4 | Hook implementation that supports reading JSON documents. | ![]() |
http_read_json/2 | Extract JSON data posted to this HTTP request. | ![]() |
http_read_json/3 | Extract JSON data posted to this HTTP request. | ![]() |
http_read_json_dict/2 | Similar to http_read_json/2,3, but by default uses the version 7 extended datatypes. | ![]() |
http_read_json_dict/3 | Similar to http_read_json/2,3, but by default uses the version 7 extended datatypes. | ![]() |
is_json_content_type/1 | True if ContentType is a header value (either parsed or as atom/string) that denotes a JSON value. | ![]() |
json_type/1 | True if MediaType is a JSON media type. | ![]() |
reply_json/1 | Formulate a JSON HTTP reply. | ![]() |
reply_json/2 | Formulate a JSON HTTP reply. | ![]() |
reply_json_dict/1 | As reply_json/1 and reply_json/2, but assumes the new dict based data representation. | ![]() |
reply_json_dict/2 | As reply_json/1 and reply_json/2, but assumes the new dict based data representation. | ![]() |
http_multipart_plugin.pl -- Multipart form-data plugin![]() | ||
http_open.pl -- HTTP client library![]() | ||
disable_encoding_filter/1 | Do not use the Content-encoding as Transfer-encoding encoding for specific values of ContentType. | ![]() |
http_close_keep_alive/1 | Close all keep-alive connections matching Address. | ![]() |
http_open/3 | Open the data at the HTTP server as a Prolog stream. | ![]() |
http_set_authorization/2 | Set user/password to supply with URLs that have URL as prefix. | ![]() |
map_method/2 | Support additional METHOD keywords. | ![]() |
open_hook/6 | Hook implementation that makes open_any/5 support http and https URLs for Mode == read . | ![]() |
http_parameters.pl -- Extract parameters (GET and POST) from HTTP requests![]() | ||
http_path.pl -- Abstract specification of HTTP server locations![]() | ||
http_server_files.pl -- Serve files needed by modules from the server![]() | ||
http_session.pl -- HTTP Session management![]() | ||
http_ssl_plugin.pl -- SSL plugin for HTTP libraries![]() | ||
http_stream.pl -- HTTP Streams![]() | ||
http_unix_daemon.pl -- Run SWI-Prolog HTTP server as a Unix system daemon![]() | ||
http_wrapper.pl -- Server processing of an HTTP request![]() | ||
hub.pl -- Manage a hub for websockets![]() | ||
jquery.pl -- Provide JQuery![]() | ||
js_grammar.pl -- JavaScript grammar![]() | ||
js_write.pl -- Utilities for including JavaScript![]() | ||
javascript/4 | Quasi quotation parser for JavaScript that allows for embedding Prolog variables to substitude identifiers in the JavaScript snippet. | ![]() |
js_arg/3 | Same as js_expression//1, but fails if Expression is invalid, where js_expression//1 raises an error. | ![]() |
js_arg_list/3 | Write javascript (function) arguments. | ![]() |
js_call/3 | Emit a call to a Javascript function. | ![]() |
js_expression/3 | Emit a single JSON argument. | ![]() |
js_new/4 | Emit a call to a Javascript object declaration. | ![]() |
js_script/3 | Generate a JavaScript script element with the given content. | ![]() |
json.pl -- Reading and writing JSON serialization![]() | ||
atom_json_dict/3 | Convert between textual representation and a JSON term represented as a dict. | ![]() |
atom_json_term/3 | Convert between textual representation and a JSON term. | ![]() |
is_json_term/1 | True if Term is a json term. | ![]() |
is_json_term/2 | True if Term is a json term. | ![]() |
json_dict_pairs/2 | This hook may be used to order the keys of an object. | ![]() |
json_read/2 | Read next JSON value from Stream into a Prolog term. | ![]() |
json_read/3 | Read next JSON value from Stream into a Prolog term. | ![]() |
json_read_dict/2 | Read a JSON object, returning objects as a dicts. | ![]() |
json_read_dict/3 | Read a JSON object, returning objects as a dicts. | ![]() |
json_write/2 | Write a JSON term to Stream. | ![]() |
json_write/3 | Write a JSON term to Stream. | ![]() |
json_write_dict/2 | Write a JSON term, represented using dicts. | ![]() |
json_write_dict/3 | Write a JSON term, represented using dicts. | ![]() |
json_write_hook/4 | Hook that can be used to emit a JSON representation for Term to Stream. | ![]() |
json_convert.pl -- Convert between JSON terms and Prolog application terms![]() | ||
current_json_object/3 | Multifile predicate computed from the json_object/1 declarations. | ![]() |
json_object/1 | Declare a JSON object. | ![]() |
json_to_prolog/2 | Translate a JSON term into an application term. | ![]() |
prolog_bool_to_json/2 | JSON is the JSON boolean for Prolog. | ![]() |
prolog_to_json/2 | Translate a Prolog application Term into a JSON object term. | ![]() |
mimetype.pl -- Determine mime-type for a file![]() | ||
term_html.pl -- Represent Prolog terms as HTML![]() | ||
term/4 | Render a Prolog term as a structured HTML tree. | ![]() |
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![]() | ||
http_open_websocket/3 | Establish a client websocket connection. | ![]() |
http_upgrade_to_websocket/3 | Create a websocket connection running call(Goal, WebSocket) , where WebSocket is a socket-pair. | ![]() |
ws_close/3 | Close a WebSocket connection by sending a close message if this was not already sent and wait for the close reply. | ![]() |
ws_mask/1 | Produce a good random number of the mask of a client message. | ![]() |
ws_open/3 | Turn a raw TCP/IP (or any other binary stream) into a websocket stream. | ![]() |
ws_property/2 | True if Property is a property WebSocket. | ![]() |
ws_receive/2 | Receive the next message from WebSocket. | ![]() |
ws_receive/3 | Receive the next message from WebSocket. | ![]() |
ws_send/2 | Send a message over a websocket. | ![]() |