This module implements a printer/parser for query strings and multipart/form-data contents of HTTP requests.
Query strings are typically encoded in the URLs of GET messages. Form-data is encoded in the contents of POST messages. Both are useful to send list of name=value information in HTTP requests (originally from HTML forms, lately for many other uses).
Usage:form_dict(Dict)
Dict is a dictionary of values of the attributes of a form. It is a list of form_assignment
Usage:form_assignment(Eq)
Eq is an assignment of value of an attribute of a form. It is defined by:
form_assignment(A=V) :- atm(A), form_value(V).
form_value(A) :- atm(A). form_value(N) :- num(N). form_value(L) :- list(string,L).
Usage:form_value(V)
V is a value of an attribute of a form.
Usage:value_dict(Dict)
Dict is a dictionary of values. It is a list of pairs atom=constant.
Unifies Val with the value for attribute Var in dictionary Dict. Does not fail: value is '' if not found (this simplifies the programming of form handlers when they can be accessed directly).
Usage:
Like get_form_value/3 but obtain Val as a string.
Usage:
Like get_form_value/3 but obtain Val as an atom.
Usage:
Usage:form_empty_value(Term)
Checks that Term, a value comming from a text area is empty (can have spaces, newlines and linefeeds).
Usage:form_default(Val,Default,NewVal)
Useful when a form is only partially filled, or when the executable can be invoked either by a link or by a form, to set form defaults. If the value of Val is empty then NewVal=Default, else NewVal=Val.
Dict is a dictionary of parameter values and URLArgs is the URL-encoded string of those assignments, which may appear after an URL pointing to a CGI script preceded by a '?'. Dict is computed according to the raw_form_values flag. The use of this predicate is reversible.
Usage 1:
Usage 2:
Usage:http_parse_form(Request,Dic)
Get form data Dic from HTTP request Request
define_flag(raw_form_values,[on,off],off).(See Runtime system control and flags).
If flag is on, values returned by http_parse_form/2 are always atoms, unchanged from its original value.
Usage:define_flag(Flag,FlagValues,Default)