SWI-Prolog HTTP support library
This directory provides the SWI-Prolog libraries for accessing and providing HTTP services. The client libraries come in two forms:
- The lightweight http_open.pl opens an HTTP location as a stream
- The more full-blown http_client.pl performs arbitrary HTTP requests and, depending on loaded plugins, transforms the data in a Prolog-friendly format.
The primary server-library is thread_httpd.pl, providing full-blown scalable embedded HTTP server.
Further reading
- ../../packages/http.pdf
- ../../packages/examples/http contains some demos.
- http://www.swi-prolog.org/pldoc/package/http.html
Prolog files
ax.pl -- Attribute Exchange library | ||
---|---|---|
ax_alias/2 | True when Alias is an alias name for the AX schema URL. | |
ax_form_attributes/2 | True if Values is a list Alias(Value) for each exchanged attribute. | |
http_ax_attributes/2 | True when HTTPAttributes is a list of Name=Value pairs that can be used with an HTTP request to query for the attributes Spec. | |
html_head.pl -- Automatic inclusion of CSS and scripts links | ||
html_current_resource/1 | True when About is a currently known resource. | |
html_requires/3 | Include ResourceOrList and all dependencies derived from it and add them to the HTML head using html_post/2. | |
html_resource/2 | Register an HTML head resource. | |
mime_include/4 | Hook called to include a link to an HTML resource of type Mime into the HTML head. | |
html_quasiquotations.pl -- HTML quasi quotations | ||
html/4 | The predicate html/4 implements HTML quasi quotations. | |
html_write.pl -- Write HTML text | ||
http_authenticate.pl -- Authenticate HTTP connections using 401 headers | ||
http_authenticate/3 | True if Request contains the information to continue according to Type. | |
http_authorization_data/2 | Decode the HTTP Authorization header. | |
http_current_user/3 | True when User is present in the htpasswd file File and Fields provides the additional fields. | |
http_read_passwd_file/2 | Read a password file. | |
http_write_passwd_file/2 | Write password data Data to File. | |
authenticate/3 | Plugin for library(http_dispatch) to perform basic HTTP authentication. | |
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 | ||
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_dirindex.pl -- HTTP directory listings | ||
mime_type_icon/2 | Multi-file hook predicate that can be used to associate icons to files listed by http_reply_dirindex/3. | |
directory_index/4 | Show index for a directory. | |
http_reply_dirindex/3 | Provide a directory listing for Request, assuming it is an index for the physical directrory Dir. | |
http_dispatch.pl -- Dispatch requests in the HTTP server | ||
http_404/2 | Reply using an "HTTP 404 not found" page. | |
http_current_handler/2 | True if Location is handled by Closure. | |
http_current_handler/3 | Resolve the current handler and options to execute it. | |
http_delete_handler/1 | Delete handler for Spec. | |
http_dispatch/1 | Dispatch a Request using http_handler/3 registrations. | |
http_handler/3 | Register Closure as a handler for HTTP requests. | |
http_link_to_id/3 | HREF is a link on the local server to a handler with given ID, passing the given Parameters. | |
http_location_by_id/2 | Find the HTTP Location of handler with ID. | |
http_redirect/3 | Redirect to a new location. | |
http_reload_with_parameters/3 | Create a request on the current handler with replaced search parameters. | |
http_reply_file/3 | Options is a list of. | |
http_safe_file/2 | True if FileSpec is considered safe. | |
http_switch_protocol/2 | Send an "HTTP 101 Switching Protocols" reply. | |
http_error.pl -- Decorate uncaught HTTP exceptions with stack-trace | ||
http_exception.pl -- Map Prolog exceptions to HTTP errors | ||
http_header.pl -- Handling HTTP headers | ||
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. | |
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 | Generate a description of a Time 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 | ||
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_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_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. | |
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_log.pl -- HTTP Logging module | ||
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. | |
nolog_post_content_type/1 | Multifile hook called with the Content-type header. | |
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_convert_data/4 | Convert multipart/form-data messages for http_read_data/3. | |
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. | |
open_options/2 | This hook is used by the HTTP client library to define default options based on the the broken-down request-URL. | |
update_cookies/3 | Update the cookie database. | |
write_cookies/3 | Emit a Cookie: header for the current connection. | |
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. | |
open_hook/6 | Hook implementation that makes open_any/5 support http and https URLs for Mode == read . | |
http_openid.pl -- OpenID consumer and server library | ||
openid_associate/3 | Calls openid_associate/4 as. | |
openid_associate/4 | Associate with an open-id server. | |
openid_authenticate/4 | Succeeds if Request comes from the OpenID server and confirms that User is a verified OpenID user. | |
openid_current_host/3 | Find current location of the server. | |
openid_current_url/2 | Find the public URL for Request that we can make available to our identity provider. | |
openid_grant/1 | Handle the reply from checkid_setup_server/3. | |
openid_hook/1 | Call hook on the OpenID management library. | |
openid_logged_in/1 | True if session is associated with OpenID. | |
openid_login/1 | Associate the current HTTP session with OpenID. | |
openid_login_form/4 | Create the OpenID form. | |
openid_logout/1 | Remove the association of the current session with any OpenID. | |
openid_server/2 | Realise the OpenID server. | |
openid_server/3 | True if OpenIDLogin is the typed id for OpenID verified by Server. | |
openid_user/3 | True if OpenID is a validated OpenID associated with the current session. | |
openid_verify/2 | Handle the initial login form presented to the user by the relying party (consumer). | |
http_parameters.pl -- Extract parameters (GET and POST) from HTTP requests | ||
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 | ||
location/3 | Multifile hook used to specify new HTTP locations. | |
http_absolute_location/3 | Path is the HTTP location for the abstract specification Spec. | |
http_absolute_uri/2 | URI is the absolute (i.e., starting with http:// ) URI for the abstract specification Spec. | |
http_clean_location_cache/0 | HTTP locations resolved through http_absolute_location/3 are cached. | |
http_server_files.pl -- Serve files needed by modules from the server | ||
serve_files_in_directory/2 | Serve files from the directory Alias from the path-info from Request. | |
http_session.pl -- HTTP Session management | ||
http_close_session/1 | Closes an HTTP session. | |
http_current_session/2 | Enumerate the current sessions and associated data. | |
http_in_session/1 | True if SessionId is an identifier for the current session. | |
http_open_session/2 | Establish a new session. | |
http_session_assert/1 | Versions of assert/1, retract/1 and retractall/1 that associate data with the current HTTP session. | |
http_session_asserta/1 | Versions of assert/1, retract/1 and retractall/1 that associate data with the current HTTP session. | |
http_session_cookie/1 | Generate a random cookie that can be used by a browser to identify the current session. | |
http_session_data/1 | True if Data is associated using http_session_assert/1 to the current HTTP session. | |
http_session_id/1 | True if SessionId is an identifier for the current session. | |
http_session_option/1 | True if Option is a current option of the session system. | |
http_session_retract/1 | Versions of assert/1, retract/1 and retractall/1 that associate data with the current HTTP session. | |
http_session_retractall/1 | Versions of assert/1, retract/1 and retractall/1 that associate data with the current HTTP session. | |
http_set_session/1 | Overrule a setting for the current or specified session. | |
http_set_session/2 | Overrule a setting for the current or specified session. | |
http_set_session_options/1 | Set options for the session library. | |
http_ssl_plugin.pl -- SSL plugin for HTTP libraries | ||
http_connection_over_proxy/6 | Facilitate an HTTPS connection via a proxy using HTTP CONNECT. | |
http_protocol_hook/5 | Hook for http_open/3 to connect to an HTTPS (SSL-based HTTP) server. | |
open_options/2 | Implementation of the multifile hook http:open_options/2 used by library(http/http_open). | |
ssl_server_create_hook/3 | Extensible predicate that is called once after creating an HTTPS server. | |
ssl_server_open_client_hook/3 | Extensible predicate that is called before each connection that the server negotiates with a client. | |
accept_hook/2 | Implement the accept for HTTPS connections. | |
make_socket_hook/3 | Hook into http_server/2 to create an SSL server if the option ssl(SSLOptions) is provided. | |
http_stream.pl -- HTTP Streams | ||
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 sofar. | |
cgi_open/4 | Process CGI output. | |
cgi_property/2 | Inquire the status of the CGI stream. | |
cgi_set/2 | Change one of the properies. | |
cgi_statistics/1 | Return statistics on the CGI stream subsystem. | |
http_chunked_open/3 | Create a stream to realise HTTP chunked encoding or decoding. | |
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 -- Run SWI-Prolog HTTP server as a Unix system daemon | ||
http_wrapper.pl -- Server processing of an HTTP request | ||
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. | |
http_wrapper/5 | Simple wrapper to read and decode an HTTP header from `In', call :Goal while watching for exceptions and send the result to the stream `Out'. | |
hub.pl -- Manage a hub for websockets | ||
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_send/2 | Send message to the indicated ClientId. | |
jquery.pl -- Provide JQuery | ||
js_grammar.pl -- JavaScript grammar | ||
js_token/3 | Matches and classifies the next JavaScript token. | |
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_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_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_to_json/2 | Translate a Prolog application Term into a JSON object term. | |
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 | ||
mime_extension/2 | Hook that is called by file_mime_type/2 before the default table is examined. | |
file_mime_type/2 | True when MimeType is the mime-type to be used for sending FileName. | |
term_html.pl -- Represent Prolog terms as HTML | ||
blob_rendering/5 | Hook to render blob atoms as HTML. | |
term/4 | Render a Prolog term as a structured HTML tree. | |
thread_httpd.pl -- Threaded HTTP server | ||
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. | |
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_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. | |
yadis.pl -- Yadis discovery | ||
xrds_dom/2 | True when XRDS_DOM is a parsed XML document for the given resource. | |
xrds_location/2 | Discover the location of the XRDS document from the given Id. | |
xrds_specified_location/2 | Hook that allows for specifying locations of XRDS documents. |