Handle an HTTP request where In is an input stream from the
client, Out is an output stream to the client and Goal
defines the goal realising the body. Connection is unified to
’Keep-alive'
if both ends of the connection want to
continue the connection or close
if either side wishes to
close the connection.
This predicate reads an HTTP request-header from In,
redirects current output to a memory file and then runs call(Goal,
Request)
, watching for exceptions and failure. If Goal
executes successfully it generates a complete reply from the created
output. Otherwise it generates an HTTP server error with additional
context information derived from the exception.
http_wrapper/5
supports the following options:
- request(-Request)
- Return the executed request to the caller.
- peer(+Peer)
- Add peer(Peer) to the request header handed to Goal. The
format of Peer is defined by tcp_accept/3
from the clib package.
This multifile hook predicate is called just before the goal
that produces the body, while the output is already redirected to
collect the reply. If it succeeds it must return a valid modified
request. It is allowed to throw exceptions as defined in
section 3.1.1. It is intended for
operations such as mapping paths, deny access for certain requests or
manage cookies. If it writes output, these must be HTTP header fields
that are added before header fields written by the body. The
example below is from the session management library (see section
3.5) sets a cookie.
...,
format('Set-Cookie: ~w=~w; path=~w~n', [Cookie, SessionID, Path]),
...,
Convert an absolute path (without host, fragment or search) into a path
relative to the current page, defined as the path component from the
current request (see http_current_request/1).
This call is intended to create reusable components returning relative
paths for easier support of reverse proxies.
If ---for whatever reason--- the conversion is not possible it simply
unifies RelPath to AbsPath.