- http_convert_data(+In, +Fields, -Data, +Options) is semidet[multifile, library(http/http_client)]
- Multi-file hook to convert a HTTP payload according to the Content-Type header. The default implementation deals with application/x-prolog. The HTTP framework provides implementations for JSON (library(http/http_json)), HTML/XML (library(http/http_sgml_plugin))
- http_client:http_convert_data(+In, +Fields, -Data, +Options) is semidet[multifile, library(http/http_multipart_plugin)]
- Convert
multipart/form-data
messages for http_read_data/3. This plugin adds the folling options to http_read_data/3:- form_data(+AsForm)
- If the content-type is
multipart/form-data
, return the form-data either in one of the following formats:- AsForm=form
- A list of Name=Value, where Value is an atom.
- AsForm=mime
- A list of
mime(Properties, Value, [])
. This is a backward compatibility mode, emulatinglibrary(http/http_mime_plugin)
. Note that if the disposition contains afilename
property, the data is read as binary unless there is a charset parameter in the Content-Type stating otherwise, while the old library would use UTF-8 for text files.
- input_encoding(+Encoding)
- Encoding to be used for parts that have no
filename
disposition and no Content-Type with a charset indication. This is typically the case for input widgets and browsers encode this using the encoding of the page. As the SWI-Prolog http library emits pages in UTF-8, the default isutf8
. - on_filename(:CallBack)
- If a part with a
filename
disposition is found and this option is given, call CallBack as below. Stream is the multipart input stream, which has octet (raw) encoding. Value is returned as result. Note that the callback may wish to save the result into a file and return e.g.,file(Path)
to indicate where the file was saved.call(:CallBack, +Stream, -Value, +Options).
The Options list contains information from the part header. It always contains
name(Name)
andfilename(FileName)
. It may contain a termmedia(Type/SubType, Params)
if the part contains a Content-Type header.
- http_client:http_convert_data(+In, +Fields, -Data, +Options)[multifile, library(http/http_json)]
- Hook implementation that supports reading JSON documents. It
processes the following option:
- json_object(+As)
- Where As is one of
term
ordict
. If the value isdict
, json_read_dict/3 is used.
- http_client:http_convert_data(+In, +Fields, -Data, +Options)[multifile, library(http/http_json)]
- Hook implementation that supports reading JSON documents. It
processes the following option:
- json_object(+As)
- Where As is one of
term
ordict
. If the value isdict
, json_read_dict/3 is used.
- http_client:http_convert_data(+In, +Fields, -Data, +Options) is semidet[multifile, library(http/http_multipart_plugin)]
- Convert
multipart/form-data
messages for http_read_data/3. This plugin adds the folling options to http_read_data/3:- form_data(+AsForm)
- If the content-type is
multipart/form-data
, return the form-data either in one of the following formats:- AsForm=form
- A list of Name=Value, where Value is an atom.
- AsForm=mime
- A list of
mime(Properties, Value, [])
. This is a backward compatibility mode, emulatinglibrary(http/http_mime_plugin)
. Note that if the disposition contains afilename
property, the data is read as binary unless there is a charset parameter in the Content-Type stating otherwise, while the old library would use UTF-8 for text files.
- input_encoding(+Encoding)
- Encoding to be used for parts that have no
filename
disposition and no Content-Type with a charset indication. This is typically the case for input widgets and browsers encode this using the encoding of the page. As the SWI-Prolog http library emits pages in UTF-8, the default isutf8
. - on_filename(:CallBack)
- If a part with a
filename
disposition is found and this option is given, call CallBack as below. Stream is the multipart input stream, which has octet (raw) encoding. Value is returned as result. Note that the callback may wish to save the result into a file and return e.g.,file(Path)
to indicate where the file was saved.call(:CallBack, +Stream, -Value, +Options).
The Options list contains information from the part header. It always contains
name(Name)
andfilename(FileName)
. It may contain a termmedia(Type/SubType, Params)
if the part contains a Content-Type header.