• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

3.16 library(http/http_host): Obtain public server location
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • The HTTP server libraries
          • library(http/http_host): Obtain public server location
            • http_public_url/2
            • http_public_host_url/2
            • http_public_host/4
            • http_current_host/4
Availability::- use_module(library(http/http_host)).
Source[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 (default false), try to replace a local hostname by a world-wide accessible name.

This predicate performs the following steps to find the host and port:

  1. Use the settings http:public_host and http:public_port
  2. Use X-Forwarded-Host header, which applies if this server runs behind a proxy.
  3. Use the Host header, which applies for HTTP 1.1 if we are contacted directly.
  4. 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.
ClioPatria (version V3.1.1-51-ga0b30a5)