Send (HttpRequest function)

From m204wiki
Revision as of 21:58, 15 June 2011 by JALWiccan (talk | contribs) (1 revision)
Jump to navigation Jump to search

Template:HTTPRequest:Send subtitle

The Send function sends an HTTP request to an HTTP server using a parameter value to identify which of the HTTP method types (GET, POST, DELETE, and so on) you want the function to perform. Any HTTP method type is valid as long as its name is 16 characters or less.

The HTTP method type is specified with the Method (name required) parameter. If the Method value is GET or POST, the Send method invocation becomes equivalent to the Get or Post method.

Prior to the addition of the Send method in Sirius Mods version 7.2, the HTTPRequest class had methods only for HTTP GETs and POSTs. The Send method is the only way to carry out HTTP methods other than GET or POST.

Syntax

Template:HTTPRequest:Send syntax

Syntax terms

%httpresp A reference to the HTTPResponse object instantiated and returned by this Send method.
%httpreq An instantiated HTTPRequest object that contains the request (its methods were used to create the request).
Port=name A string expression that identifies a previously defined Janus CLSOCK port. The name default is the MASTER port, if any is defined. However, if you omit name and no MASTER port is defined, the request is cancelled.

This argument is optional, but if you specify a value, the parameter name, Port (case not important), is allowed as a qualifier.

Cancel=num A numeric expression that controls whether the request is cancelled if a communication/socket error occurs. If zero, the request is not cancelled on these errors. If non-zero, the request is cancelled (though a message is still issued). If not specified, it defaults to 1 (cancel). See below for further discussion of error handling.

This argument is optional, but if you specify a value, the parameter name, Cancel (case not important), is allowed as a qualifier.

Method=methodname The quoted name of any HTTP method type (for example, 'GET', 'PUT', 'MOVE'), as long as it is less than or equal to 16 characters long, all uppercase.

This argument is required, and the parameter name, Method (case not important), is a required qualifier.

Usage notes

  • Although you may specify the Method parameter before the optional parameters, you receive a compilation error if you do so without also specifying the optional parameter names with the optional parameters.
  • For information about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.
  • For information about error handling, see, for example, the Get function "Usage notes".
  • To send an HTTP GET or POST, you can also use the Get method or the Post method, respectively.

Examples

Send statements with argument variations are shown below:

%resp = %req:send(method='DELETE') %resp = %req:send('CLPORT', method='DELETE') %resp = %req:send(method='POST', port='CLPORT', cancel=1)

See also

Template:HTTPRequest:Send footer