This plugin for library(http_client) automatically translates messages
multipart/form-data into a list of Name = Value
pairs, greatly simplifying the processing of forms with this type.
- http_client:http_convert_data(+In, +Fields, -Data, +Options) is semidet[multifile]
multipart/form-datamessages for http_read_data/3. This plugin adds the folling options to http_read_data/3:
- If the content-type is
multipart/form-data, return the form-data either in one of the following formats:
- A list of Name=Value, where Value is an atom.
- A list of
mime(Properties, Value, ). This is a backward compatibility mode, emulating
library(http/http_mime_plugin). Note that if the disposition contains a
filenameproperty, 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.
- Encoding to be used for parts that have no
filenamedisposition 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 is
- If a part with a
filenamedisposition 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
filename(FileName). It may contain a term
media(Type/SubType, Params)if the part contains a Content-Type header.
- multipart_type(+Type, -Boundary) is semidet[private]
- True if Type is of the form
multipart/form-data; boundary="..."and Boundary is a string describing the boundary.
- part_header(+PartHeader, -Params, -Name, -Encoding) is det[private]
- Extract the form-field Name, the content Encoding and possible
other properties of the form-field. Extra properties are:
- part_value(+Stream, +Name, +Params, +Encoding, -Part, +Options)[private]