:- module(http_client).
:- export http_open / 2.
:- export http_compile / 2.
:- export http_compile / 1.
:- export http_client / 7.
:- tool(http_compile / 1,http_compile / 2).
:- comment(http_compile / 2, hidden).
:- comment(summary, "HTTP client library").
:- comment(author, "Ph. Bonnet, S. Bressan and M. Meier, ECRC Munich").
:- comment(copyright, "Cisco Systems, Inc").
:- comment(date, "$Date: 2006/09/23 01:55:19 $").
:- comment(http_client / 7, [template : "http_client(+Method, +Uri, +ObjectBody, +HttpParams, -RespError, -RespParam, -RespObjectBody)", summary : "Used to access HTML pages, given their URI (the method GET is applied)", args : ["Method" : "A string", "Uri" : "A string", "ObjectBody" : "A string", "HttpParams" : "A list of terms as defined in the DCG grammar", "RespError" : "Outputs a term error(ErrorCode, ErrorPhrase),\n\twhere ErrorCode is he error code contained in the response\n\tand ErrorPhrase is the error phrase contained in the response", "RespParam" : "Outputs a list of terms as defined in the DCG grammar", "RespObjectBody" : "Outputs the object body of the response"], eg : "\n    [eclipse 1]: use_module(http).\n    http_grammar.pl compiled traceable 25048 bytes in 0.38 seconds\n    http_client.pl compiled traceable 5916 bytes in 0.47 seconds\n    http_server.pl compiled traceable 5304 bytes in 0.07 seconds\n    http.pl    compiled traceable 0 bytes in 0.57 seconds\n\n    yes.\n    [eclipse 2]:  http_client(\"GET\", \"http://www.ecrc.de/staff/\", \"\", [],\n\t    Status, Param, Resp).\n\n    Status = error(200, \"Document follows \")\n    Param = [date, server, contentType(mt(text, html))]\n\n    Resp = \"<HTML>...</HTML>\"\n\n    yes.\n    "]).
:- comment(http_compile / 1, [template : "http_compile(+Url)", summary : "Compile an ECLiPSe source file, given its URL", args : ["Url" : "A string"], desc : html("This utility downloads an eclipse source file (given its URL)\n    and compiles it. Note that this represents a security risk: the downloaded\n    code may contain Eclipse commands that are executed on your computer.\n    Make sure you trust the code that you download!"), eg : "\n    [eclipse 1]: lib(http_client).\n    yes.\n    [eclipse 2]: http_compile(\"http://icparc.ic.ac.uk/eclipse/examples/sendmore.pl\").\n    yes.\n    [eclipse 8]: sendmore1(X).\n    X = [9, 5, 6, 7, 1, 0, 8, 2]     More? (;) \n    no (more) solution.\n    "]).
:- comment(http_open / 2, [template : "http_open(+Url, -Stream)", summary : "Download a web document given its URL and open a Stream to read it", args : ["Url" : "A string", "Stream" : "A variable or atom"], desc : html("This utility downloads a web document (given its URL) into a\n    string stream and returns that string stream's identifier for reading."), eg : "\n    [eclipse 1]: lib(http_client).\n    yes.\n    [eclipse 2]: http_open(\"http://icparc.ic.ac.uk/index.html\",S),\n                 read_string(S, end_of_line, _, L).\n    S = 19\n    L = \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 3.2//EN\\\">\"\n    yes.\n    "]).
