Most code doesn't need to use this directly; instead use
library(http/http_server), which combines this library with the
typical HTTP libraries that most servers need.
This library provides the core of the implementation of the HTTP
protocol at the server side and is mainly intended for internal use.
It is used by
Still, it provides a few predicates that are occasinally useful for
- http_current_request/1 finds the current request for occasional
usage in places where it is not avaialable otherwise.
- http_peer/2 finds the (IP4) peer address, getting the original
address if we are behind a proxy (
- http_relative_path/2 can be used to find a relative path from
the current request.
- http_wrapper(:Goal, +In, +Out, -Close, +Options) is det
- Simple wrapper to read and decode an HTTP header from `In', call
:Goal while watching for exceptions and send the result to the
The goal is assumed to write the reply to
preceeded by an HTTP header, closed by a blank line. The header
must contain a Content-type: <type> line. It may optionally
contain a line
Transfer-encoding: chunked to request chunked
- Return the full request to the caller
- IP address of client
|Close||- Unified to one of |
- http_wrap_spawned(:Goal, -Request, -Close) is det
- Internal use only. Helper for wrapping the handler for
- See also
- - http_spawned/1, http_spawn/2.
- Internal use only. Indicate that the request is handed to thread
- cgi_hook(+Event, +CGI) is det
- Hook called from the CGI processing stream. See http_stream.pl
- This API provides an alternative for writing the header field as
a CGI header. Header has the format Name(Value), as produced by
- - Use CGI lines instead
- http_current_request(-Request) is semidet
- Returns the HTTP request currently being processed. Fails
silently if there is no current request. This typically happens
if a goal is run outside the HTTP server context.
- http_peer(+Request, -PeerIP:atom) is semidet
- True when PeerIP is the IP address of the connection peer. If the
connection is established via a proxy or CDN we try to find the
initiating peer. Currently supports:
- Direct connections
- - The
X-forwarded-for header is problematic. According to
original client is the first, while according to
it is the last.
- http_relative_path(+AbsPath, -RelPath) is det
- Convert an absolute path (without host, fragment or search) into
a path relative to the current page. This call is intended to
create reusable components returning relative paths for easier
support of reverse proxies.