
http_server.pl -- HTTP server library
This library combines the core server functionality provided by several libraries that are needed by almost any web server. It exports the commonly used predicates from library(http/thread_httpd), library(http/http_dispatch), library(http/http_wrapper), library(http/http_parameters), library(http/html_write), library(http/http_json), and library(http/http_dyn_workers).
http_server(+Options) is det- Create an HTTP server using http_dispatch/1 for handling requests. See http_server/2 and http_dispatch/1 for details.
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
reply_html_page(:Head, :Body) is det
reply_html_page(+Style, :Head, :Body) is det- Provide the complete reply as required by http_wrapper.pl for a page
constructed from Head and Body. The HTTP
Content-typeis provided by html_current_option/1.
html_meta(+Heads) is det- This directive can be used to declare that an HTML rendering
rule takes HTML content as argument. It has two effects. It
emits the appropriate meta_predicate/1 and instructs the
built-in editor (PceEmacs) to provide proper colouring for the
arguments. The arguments in Head are the same as for
meta_predicate or can be constant
html. For example::- html_meta page(html,html,?,?).
is_json_content_type(+ContentType) is semidet- True if ContentType is a header value (either parsed or as atom/string) that denotes a JSON value.
http_read_json_dict(+Request, -Dict) is det
http_read_json_dict(+Request, -Dict, +Options) is det- Similar to http_read_json/2,3, but by default uses the version 7 extended datatypes.
http_read_json_dict(+Request, -Dict) is det
http_read_json_dict(+Request, -Dict, +Options) is det- Similar to http_read_json/2,3, but by default uses the version 7 extended datatypes.
reply_json_dict(+JSONTerm) is det
reply_json_dict(+JSONTerm, +Options) is det- As reply_json/1 and reply_json/2, but assumes the new dict based data representation. Note that this is the default if the outer object is a dict. This predicate is needed to serialize a list of objects correctly and provides consistency with http_read_json_dict/2 and friends.
reply_json_dict(+JSONTerm) is det
reply_json_dict(+JSONTerm, +Options) is det- As reply_json/1 and reply_json/2, but assumes the new dict based data representation. Note that this is the default if the outer object is a dict. This predicate is needed to serialize a list of objects correctly and provides consistency with http_read_json_dict/2 and friends.
http_parameters(+Request, ?Parms) is det
http_parameters(+Request, ?Parms, :Options) is det- Get HTTP GET or POST form-data, applying type validation,
default values, etc. Provided options are:
- attribute_declarations(:Goal)
- Causes the declarations for an attributed named A to be
fetched using
call(Goal, A, Declarations). - form_data(-Data)
- Return the data read from the GET por POST request as a list Name = Value. All data, including name/value pairs used for Parms, is unified with Data.
The attribute_declarations hook allows sharing the declaration of attribute-properties between many http_parameters/3 calls. In this form, the requested attribute takes only one argument and the options are acquired by calling the hook. For example:
..., http_parameters(Request, [ sex(Sex) ], [ attribute_declarations(http_param) ]), ... http_param(sex, [ oneof(male, female), description('Sex of the person') ]).
http_parameters(+Request, ?Parms) is det
http_parameters(+Request, ?Parms, :Options) is det- Get HTTP GET or POST form-data, applying type validation,
default values, etc. Provided options are:
- attribute_declarations(:Goal)
- Causes the declarations for an attributed named A to be
fetched using
call(Goal, A, Declarations). - form_data(-Data)
- Return the data read from the GET por POST request as a list Name = Value. All data, including name/value pairs used for Parms, is unified with Data.
The attribute_declarations hook allows sharing the declaration of attribute-properties between many http_parameters/3 calls. In this form, the requested attribute takes only one argument and the options are acquired by calling the hook. For example:
..., http_parameters(Request, [ sex(Sex) ], [ attribute_declarations(http_param) ]), ... http_param(sex, [ oneof(male, female), description('Sex of the person') ]).
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
http_dispatch(Arg1)
http_current_request(Arg1)
http_add_worker(Arg1, Arg2)
http_reload_with_parameters(Arg1, Arg2, Arg3)
http_current_server(Arg1, Arg2)
http_current_handler(Arg1, Arg2)
http_reply_file(Arg1, Arg2, Arg3)
http_peer(Arg1, Arg2)
html(Arg1, Arg2, Arg3)
http_current_worker(Arg1, Arg2)
http_link_to_id(Arg1, Arg2, Arg3)
http_server_property(Arg1, Arg2)
http_switch_protocol(Arg1, Arg2)
http_request_expansion(Arg1, Arg2)
http_delete_handler(Arg1)
http_stop_server(Arg1, Arg2)
http_server(Arg1, Arg2)
http_location_by_id(Arg1, Arg2)
http_404(Arg1, Arg2)
http_handler(Arg1, Arg2, Arg3)
http_spawn(Arg1, Arg2)
http_workers(Arg1, Arg2)
http_current_handler(Arg1, Arg2, Arg3)
http_redirect(Arg1, Arg2, Arg3)