| Did you know ... | Search Documentation: |
| http_client.pl -- HTTP client library |
This library provides the four basic HTTP client actions: GET,
DELETE, POST and PUT. In addition, it provides http_read_data/3,
which is used by library(http/http_parameters) to decode POST data in
server applications.
This library is based on http_open/3, which opens a URL as a Prolog stream. The reply is processed by http_read_data/3. The following content-types are supported. Options passed to http_get/3 and friends are passed to http_read_data/3, which in turn passes them to the conversion predicates. Support for additional content types can be added by extending the multifile predicate http_client:http_convert_data/4.
Name=Value terms.json_object(As) can be used to return a term json(Attributes)
(As is term) or a dict (As is dict).
http_get(+URL, -Data, +Options) is detContent-Type header and plugins.
This predicate is the common implementation of the HTTP client
operations. The predicates http_delete/3, http_post/4 and
http_put/4 call this predicate with an appropriate
method(+Method) option and ---for http_post/4 and http_put/4---
a post(+Data) option.
Options are passed to http_open/3 and http_read_data/3. Other options:
headers(Fields) from http_open/3. Provided for
backward compatibility. Note that http_version(Major-Minor)
is missing in the new version.
http_delete(+URL, -Data, +Options) is detDELETE method on the server. Arguments are the same
as for http_get/3. Typically one should pass the option
status_code(-Code) to assess and evaluate the returned status
code. Without, codes other than 200 are interpreted as an error.
http_post(+URL, +Data, -Reply, +Options) is detPOST request. Data is posted using
http_post_data/3. The HTTP server reply is returned in Reply,
using the same rules as for http_get/3.
http_put(+URL, +Data, -Reply, +Options)PUT request. Arguments are the same as for
http_post/4.
http_patch(+URL, +Data, -Reply, +Options)PATCH request. Arguments are the same as for
http_post/4.
http_read_data(+Request, -Data, +Options) is detto(Format) option or based on the Content-type
in the Request. The following options are supported:
stream(+WriteStream))
Append the content of the message to Streammultipart/form-data content.Without plugins, this predicate handles
Name=Value terms.
http_convert_data(+In, +Fields, -Data, +Options) is semidet[multifile]
http_disconnect(+Connections) is detall, closing all connections.
http:post_data_hook(+Term, +Out, +Options) is semidet[multifile]post(Data) option
of http_open/3. The default implementation supports
prolog(Term), sending a Prolog term as application/x-prolog.