http.geturl — Fetch contents of a URL.


http.geturl url [-query POSTdata] [-headers list of headers] [-validate [1|0]]


The http.geturl command performs an HTTP request to the given url and returns information about the results. This information is returned as a hash table that can be accessed with the various h* commands such as hget. The list of keys returned includes the following, which are set by Hecl. Also created as keys are the various HTTP headers, such as connection, content-length, content-type, last-modified, and so on.

  • binary: 1 if the data returned is binary, otherwise 0.

  • charset: The charset used for the returned data.

  • data: The returned data. For instance, if you fetched an ordinary web page, this would be its HTML contents.

  • ncode: The numeric code of the response, such as 404, 500, 301, and so on.

  • status: The request status - ok if the request was successfully processed.

The -query option is used to send key/value pairs of variables. In order to set random headers, the -headers argument is used. The -validate option exists to send a HEAD request.


# Evaluate Hecl script located on a web site.
eval [hget [http.geturl] data]

Add some headers to a request:

http.geturl -headers {Set-Cookie foo=bar}