- library
- http
- 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
- http_stream.pl -- HTTP Streams
- http_exception.pl -- Map Prolog exceptions to HTTP errors
- http_path.pl -- Abstract specification of HTTP server locations
- http_dispatch.pl -- Dispatch requests in the HTTP server
- http_host.pl -- Obtain public server location
- 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_multipart_plugin.pl -- Multipart form-data plugin
- http_hook.pl -- HTTP library hooks
- html_write.pl -- Write HTML text
- html_quasiquotations.pl -- HTML quasi quotations
- mimetype.pl -- Determine mime-type for a file
- html_head.pl -- Automatic inclusion of CSS and scripts links
- term_html.pl -- Represent Prolog terms as HTML
- json.pl -- Reading and writing JSON serialization
- jquery.pl -- Provide JQuery
- http_server_files.pl -- Serve files needed by modules from the server
- http_open.pl -- HTTP client library
- 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
- js_write.pl -- Utilities for including JavaScript
- js_grammar.pl -- JavaScript grammar
- 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
- mimepack.pl -- Create a MIME message
- http
- 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:
- authenticate(+Boolean)
- If
false
(defaulttrue
), do not try to automatically authenticate the client if a 401 (Unauthorized) status code is received. - authorization(+Term)
- Send authorization. See also http_set_authorization/2. Supported
schemes:
- basic(+User, +Password)
- HTTP Basic authentication.
- bearer(+Token)
- HTTP Bearer authentication.
- digest(+User, +Password)
- HTTP Digest authentication. This option is only provided if the plugin library(http/http_digest) is also loaded.
- unix_socket(+Path)
- Connect to the given Unix domain socket. In this scenario
the host name and port or ignored. If the server replies
with a redirect message and the host differs from the
original host as normal TCP connection is used to handle
the redirect. This option is inspired by
curl(1)
's option `--unix-socket`. - connection(+Connection)
- Specify the
Connection
header. Default isclose
. The alternative isKeep-alive
. This maintains a pool of available connections as determined by keep_connection/1. Thelibrary(http/websockets)
usesKeep-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. - final_url(-FinalURL)
- 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 ('').
- headers(-List)
- 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
header(Name,Value)
option. See alsoraw_headers(-List)
which provides the entire HTTP reply header in unparsed representation. - method(+Method)
- One of
get
(default),head
,delete
,post
,put
orpatch
. Thehead
message can be used in combination with theheader(Name, Value)
option to access information on the resource without actually fetching the resource itself. The returned stream must be closed immediately.If
post(Data)
is provided, the default ispost
. - size(-Size)
- Size is unified with the integer value of
Content-Length
in the reply header. - version(-Version)
- Version is a pair
Major-Minor
, where Major and Minor are integers representing the HTTP version in the reply header. - range(+Range)
- Ask for partial content. Range is a term Unit(From,To),
where From is an integer and To is either an integer or
the atom
end
. HTTP 1.1 only supports Unit =bytes
. E.g., to ask for bytes 1000-1999, use the optionrange(bytes(1000,1999))
- raw_encoding(+Encoding)
- Do not install a decoding filter for Encoding. For example,
using
raw_encoding('applocation/gzip')
the system will not decompress the stream if it is compressed usinggzip
.