This library provides the four basic HTTP client actions:
addition, it provides http_read_data/3,
which is used by
library(http/http_parameters) to decode
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.
library(http/http_multipart_plugin)is loaded. This format should be used to handle web forms that upload a file.
library(http/http_sgml_plugin)is loaded. See load_html/3 for details and load_xml/3 for details. The output is often processed using xpath/3.
library(http/http_json)is loaded. The option
json_object(As)can be used to return a term
term) or a dict (As is
Content-typeheader 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
headers(Fields)from http_open/3. Provided for backward compatibility. Note that
http_version(Major-Minor)is missing in the new version.
DELETEmethod 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.
POSTrequest. 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.
PUTrequest. Arguments are the same as for http_put/4.
input(In)that provides the input stream from the HTTP server. Fields is the parsed http reply-header. Options is one of:
stream(+WriteStream)) Append the content of the message to Stream
library(http/http_multipart_plugin)and apply to processing
Without plugins, this predicate handles
|Request||is a parsed HTTP request as returned by http_read_request/2 or available from the HTTP server's request dispatcher.|
library(http/http_json)), HTML/XML (
all, closing all connections.
post(Data)option of http_open/3. The default implementation supports
prolog(Term), sending a Prolog term as