- Documentation
- Reference manual
- Packages
- SWI-Prolog HTTP support
- The HTTP server libraries
- Creating an HTTP reply
- library(http/http_dispatch): Dispatch requests in the HTTP server
- library(http/http_dirindex): HTTP directory listings
- library(http/http_files): Serve plain files from a hierarchy
- library(http/http_session): HTTP Session management
- library(http/http_cors): Enable CORS: Cross-Origin Resource Sharing
- library(http/http_authenticate): Authenticate HTTP connections using 401 headers
- library(http/http_digest): HTTP Digest authentication
- library(http/http_dyn_workers): Dynamically schedule HTTP workers.
- Custom Error Pages
- library(http/http_openid): OpenID consumer and server library
- Get parameters from HTML forms
- Request format
- Running the server
- The wrapper library
- library(http/http_host): Obtain public server location
- library(http/http_log): HTTP Logging module
- Debugging HTTP servers
- library(http/http_header): Handling HTTP headers
- The library(http/html_write) library
- library(http/js_write): Utilities for including JavaScript
- library(http/http_path): Abstract specification of HTTP server locations
- library(http/html_head): Automatic inclusion of CSS and scripts links
- library(http/http_pwp): Serve PWP pages through the HTTP server
- The HTTP server libraries
- SWI-Prolog HTTP support
3.16 library(http/http_host): Obtain public server location
This library finds the public address of the running server. This can
be used to construct URLs that are visible from anywhere on the
internet. This module was introduced to deal with OpenID, where a
request is redirected to the OpenID server, which in turn redirects to
our server (see http_openid.pl
).
The address is established from the settings http:public_host
and
http:public_port
if provided. Otherwise it is deduced from
the request.
- [det]http_public_url(+Request, -URL)
- True when URL is an absolute URL for the current request. Typically, the login page should redirect to this URL to avoid losing the session.
- [det]http_public_host_url(+Request, -URL)
- True when URL is the public URL at which this server can be contacted. This value is not easy to obtain. See http_public_host/4 for the hardest part: find the host and port.
- [det]http_public_host(?Request, -Hostname, -Port, +Options)
- Current global host and port of the HTTP server. This is the basis to
form absolute address, which we need for redirection based interaction
such as the OpenID protocol. Options are:
- global(+Bool)
- If
true
(defaultfalse
), try to replace a local hostname by a world-wide accessible name.
This predicate performs the following steps to find the host and port:
- Use the settings
http:public_host
andhttp:public_port
- Use
X-Forwarded-Host
header, which applies if this server runs behind a proxy. - Use the
Host
header, which applies for HTTP 1.1 if we are contacted directly. - Use gethostname/1 to find the host and http_current_server/2 to find the port.
Request is the current request. If it is left unbound, and the request is needed, it is obtained with http_current_request/1. - [det]http_current_host(?Request, -Hostname, -Port, +Options)
-
- deprecated
- Use http_public_host/4 (same semantics)