HTTP/Post - Help

HTTP

 Post
 Post data to a URL using HTTP POST and retrieve the result

 Calling Sequence Post(URI, content, options)

Parameters

 URI - host, port, and URL path of the form http://host:port/path/to/file; the uniform resource identifier content - content of the HTTP request

Options

list of header values; duplicate values will be combined into a single comma-separated list.

 • timeout=posint

the number of seconds to wait for data before timing out.

 • forcemode=name

either text or binary this forces the transfer to be done in the given mode regardless of the Content-Type reported by the server.

Description

 • Post is an extension of Get.  In addition to being able to data in the Request-URI, Post is also able to send other data to the server in the content argument.  This command is generally used to implement the sending of data via an HTML form.
 • Post returns a sequence (code, content, headers) with code set to the return code sent by the server, content containing the body of the server response, and  headers as a table.

Examples

 > $\mathrm{status},\mathrm{data},\mathrm{headers}≔\mathrm{HTTP}:-\mathrm{Post}\left("https://www.ssa.gov/cgi-bin/popularnames.cgi","year=1990&top=20&number=n",'\mathrm{headers}'=\left["Content-Type"="application/x-www-form-urlencoded"\right],'\mathrm{timeout}'=100\right):$
 > $\mathrm{HTTP}:-\mathrm{Code}\left(\mathrm{status}\right)$
 ${"OK"}$ (1)
 > $\mathrm{type}\left(\mathrm{data},'\mathrm{string}'\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{data}\left[1..39\right]$
 ${" Popular Baby Names<"}$ (3)
 > $\mathrm{type}\left(\mathrm{headers},'\mathrm{table}'\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{headers}\left["Content-Type"\right]$
 ${"text/html; charset=UTF-8"}$ (5)

Compatibility

 • The HTTP[Post] command was introduced in Maple 15.