- http_unix_daemon.pl -- Run SWI-Prolog HTTP server as a Unix system daemon
- thread_httpd.pl -- Threaded HTTP server
- http_wrapper.pl -- Server processing of an HTTP request
- http_header.pl -- Handling HTTP headers
- html_write.pl -- Write HTML text
- html_quasiquotations.pl -- HTML quasi quotations
- http_exception.pl -- Map Prolog exceptions to HTTP errors
- mimetype.pl -- Determine mime-type for a file
- mimepack.pl -- Create a MIME message
- http_stream.pl -- HTTP Streams
- http_path.pl -- Abstract specification of HTTP server locations
- http_host.pl -- Obtain public server location
- http_dispatch.pl -- Dispatch requests in the HTTP server
- http_ssl_plugin.pl -- SSL plugin for HTTP libraries
- http_parameters.pl -- Extract parameters (GET and POST) from HTTP requests
- http_client.pl -- HTTP client library
- http_open.pl -- HTTP client library
- http_multipart_plugin.pl -- Multipart form-data plugin
- http_hook.pl -- HTTP library hooks
- html_head.pl -- Automatic inclusion of CSS and scripts links
- term_html.pl -- Represent Prolog terms as HTML
- jquery.pl -- Provide JQuery
- http_server_files.pl -- Serve files needed by modules from the server
- json.pl -- Reading and writing JSON serialization
- http_session.pl -- HTTP Session management
- http_openid.pl -- OpenID consumer and server library
- yadis.pl -- Yadis discovery
- ax.pl -- Attribute Exchange library
- http_authenticate.pl -- Authenticate HTTP connections using 401 headers
- http_json.pl -- HTTP JSON Plugin module
- http_dirindex.pl -- HTTP directory listings
- http_cors.pl -- Enable CORS: Cross-Origin Resource Sharing
- json_convert.pl -- Convert between JSON terms and Prolog application terms
- http_dyn_workers.pl -- Dynamically schedule HTTP workers.
- hub.pl -- Manage a hub for websockets
- websocket.pl -- WebSocket support
- http_log.pl -- HTTP Logging module
- http_open(+URL, -Stream, +Options) is det
- Open the data at the HTTP server as a Prolog stream. URL is
either an atom specifying a URL or a list representing a
broken-down URL as specified below. After this predicate
succeeds the data can be read from Stream. After completion this
stream must be closed using the built-in Prolog predicate
close/1. Options provides additional options:
true), do not try to automatically authenticate the client if a 401 (Unauthorized) status code is received.
- Send authorization. See also http_set_authorization/2. Supported
- basic(+User, +Password)
- HTTP Basic authentication.
- HTTP Bearer authentication.
- digest(+User, +Password)
- HTTP Digest authentication. This option is only provided
if the plugin
library(http/http_digest)is also loaded.
- Specify the
Connectionheader. Default is
close. The alternative is
Keep-alive. This maintains a pool of available connections as determined by keep_connection/1. The
Keep-alive, Upgrade. Keep-alive connections can be closed explicitly using http_close_keep_alive/1. Keep-alive connections may significantly improve repetitive requests on the same server, especially if the IP route is long, HTTPS is used or the connection uses a proxy.
- Unify FinalURL with the final destination. This differs from the original URL if the returned head of the original indicates an HTTP redirect (codes 301, 302 or 303). Without a redirect, FinalURL is the same as URL if URL is an atom, or a URL constructed from the parts.
- header(Name, -AtomValue)
- If provided, AtomValue is unified with the value of the indicated field in the reply header. Name is matched case-insensitive and the underscore (_) matches the hyphen (-). Multiple of these options may be provided to extract multiple header fields. If the header is not available AtomValue is unified to the empty atom ('').
- If provided, List is unified with a list of Name(Value) pairs
corresponding to fields in the reply header. Name and Value
follow the same conventions used by the
- One of
headmessage can be used in combination with the
header(Name, Value)option to access information on the resource without actually fetching the resource itself. The returned stream must be closed immediately.
post(Data)is provided, the default is
- Size is unified with the integer value of
Content-Lengthin the reply header.
- Version is a pair
Major-Minor, where Major and Minor are integers representing the HTTP version in the reply header.
- Ask for partial content. Range is a term Unit(From,To),
where From is an integer and To is either an integer or
end. HTTP 1.1 only supports Unit =
bytes. E.g., to ask for bytes 1000-1999, use the option
true), do not automatically redirect if a 3XX code is received. Must be combined with
status_code(Code)and one of the header options to read the redirect reply. In particular, without
status_code(Code)a redirect is mapped to an exception.
- If this option is present and Code unifies with the HTTP status code, do not translate errors (4xx, 5xx) into an exception. Instead, http_open/3 behaves as if 2xx (success) is returned, providing the application to read the error document from the returned stream.
- Unify the output stream with Out and do not close it. This can be used to upgrade a connection.
- If provided, set a timeout on the stream using set_stream/2.
With this option if no new data arrives within Timeout seconds
the stream raises an exception. Default is to wait forever
- Issue a
POSTrequest on the HTTP server. Data is handed to http_post_data/3.
- Use an HTTP proxy to connect to the outside world. See also proxy_for_url/3. This option overrules the proxy specification defined by proxy_for_url/3.
- proxy(+Host, +Port)
- Synonym for
- Send authorization to the proxy. Otherwise the same as the
true, bypass proxy hooks. Default is
- Additional name-value parts are added in the order of appearance to the HTTP request header. No interpretation is done.
- Sets the maximum length of a redirection chain. This is needed
for some IRIs that redirect indefinitely to other IRIs without
looping (e.g., redirecting to IRIs with a random element in them).
Max must be either a non-negative integer or the atom
infinite. The default value is
- Defines the value of the
User-Agentfield of the HTTP header. Default is
The hook http:open_options/2 can be used to provide default options based on the broken-down URL. The option
status_code(-Code)is particularly useful to query REST interfaces that commonly return status codes other than
200that need to be be processed by the client code.
URL - is either an atom or string (url) or a list of parts.
When provided, this list may contain the fields
query_string(whose argument is an atom) or
search(whose argument is a list of
Name=Valuecompound terms). Only
hostis mandatory. The example below opens the URL
http://www.example.com/my/path?q=Hello%20World&lang=en. Note that values must not be quoted because the library inserts the required quotes.
http_open([ host('www.example.com'), path('/my/path'), search([ q='Hello world', lang=en ]) ])
error(existence_error(url, Id),Context)is raised if the HTTP result code is not in the range 200..299. Context has the shape
context(Message, status(Code, TextCode)), where Code is the numeric HTTP code and TextCode is the textual description thereof provided by the server. Message may provide additional details or may be unbound.
- See also
- - ssl_context/3 for SSL related options if