HTTP - Send/Receive via HTTP Protocol

Usage

  value = HTTP ( tagarg... )

Parameters

  value The result depends on the tagged argument, usually the result of the HTTP call.
  tagarg One or more of the tagged argument described below.

Tagged Arguments

  Append::file Append the returned results to the specified file.
  Arg::string The arguments to be passed in this HTTP call.
  ArgFile::name If the value to this tag is not a string but a dictionary point then it is taken as the name of a V4 stream that is to be used.
  ArgFile::file The contents of file are passed as the arguments to the HTTP call.
  Bearer::string Adds an Authorization Bearer header to the HTTP request.
  Certificate::list The list is a three element list consisting of (certificate-file cerficate-password ssl-cypher-list). These are passed via the CURL CURLOPT_SSLCERT, CURLOPT_KEYPASSWD and CURLOPT_SSL_CIPHER_LIST options.
  Certificate::file Pass the file via the CURL CURLOPT_SSLCERT option.
  Cookie::namevalue The namevalue must be formatted as name=value. Multiple instances of this tag can be used for multiple cookies.
  Create::file The results of the HTTP call are saved in this file.
  DateTime::datetime Sets the HTTP Date header to datetime.
  File::file The contents of this filname are passed in the call. This must be preceded with a Name tagged argument.
  Header::dimlist This defines a dimension to receive the returned HTTP headers. The dimlist value must be a dimension of type List. The returned headers will be returned as a list of points on the Alpha dimension.
  Header::list Define an HTTP header to be passed. The format of list must be ("header-name" "header-value"). Multiple Header tags can be declared.
  Include::file Takes the contents of file as the value of the prior Name.
  Name::string Defines a named argument for the call. The following argument is taken as the value.
  Object::string The name of the target object, usually a file name or executable. If this is specified then it is appended to the end of the URL value.
  Out::id Write the returned results of the HTTP call to the V4 stream identified by id. (See the Output module for more information.)
  Password::string The password to be used by this HTTP call.
  Retry::num On an HTTP failure, retry the HTTP call up to num times before generating V4 error.
  Trace::logical If logical is TRUE then output tracing information on the call. If FALSE (default) then do not output any trace debugging information.
  Trace::file Output tracing information into the file file.
  Type::string The content-type of the HTTP call.
  URL::string The URL to be invoked.
  User::string The user name associated with this HTTP call. The User argument and Password argument are concatenated into a semi-colon delimited security token
  UserAgent::string The string is passed as the CURL option CURLOPT_USERAGENT.
  Wait::seconds Normally this module will wait 'forever' for a response back from the server. This can be limited to a maximum wait time of seconds. The module fails if no response is received within this time period.

Tagged Results

  Data? Indicates that the returned results are to be binary data. See also the Text tagged option.
  Delete? The HTTP call is to be a DELETE.
  Get? The HTTP call is to be a GET (instead of a POST).
  Post? The HTTP call is to be a POST (instead of a GET). This is the default.
  Put? The HTTP call is to be a PUT.
  Text? Indicates that the returned results are to be text data. See also the Data tagged option.

Description

This module invokes an HTTP call using the CURL library of routines. It can be used to make HTTP and HTTPS calls to any other sites on the web.

  HTTP(URL::Str([urlBase] "scripts/style.js") Create::Str([dirWebJS] "style.js")) Pulls the javascript file from the target website and saves it locally as style.js
  HTTP(URL::[urlWebServices] Post? Type::"application/soap+xml" Arg::$soap) Sends a SOAP+XML request
  HTTP(Trace::TRUE URL::[authNetGatewayXML] Post? Type::'text/xml' Arg::[anXML]) Sends an XML message to a credit card gateway with full debugging/tracing

Example 29 - Using Buffers & JSON with the HTTP Module

 
Output(Buffer? Id::xmlRequest) /* Create a new buffer stream */
Do(Out::xmlRequest [generateTaxRequestXML]) /* Generate an XML request and output to this stream */
Output(Buffer? Id::xmlResponse) /* Create another empty stream for the HTTP results */
HTTP(URL::"http://xxx.xxx.com" Post? Type::"application/soap+xml" ArgFile::xmlRequest Out::xmlResponse) /* Call HTTP with the input and output buffers*/
JSON(Parse? Ignore::(soap) Array::(message tax line) XML::xmlResponse) /* Parse/convert the resulting XML to JSON for processing */