Send (HttpRequest function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax table to syntax template; edits, tags and links)
Line 1: Line 1:
{{Template:HttpRequest:Send subtitle}}
{{Template:HttpRequest:Send subtitle}}
The <var>Send</var> 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 Send function sends an HTTP request to an HTTP server
The HTTP method type is specified with the <var class="term">Method</var> ([[Notation conventions for methods#Named parameters|name required]]) parameter.  If the <var class="term">Method</var> value is <code>GET</code> or <code>POST</code>, the <var>Send</var> method invocation becomes equivalent to the <var>[[Get (HttpRequest function)|Get]]</var> or [[Post (HttpRequest function)|Post]] method.
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 <var>Method</var>
Prior to the addition of the <var>Send</var> method in <var class="product">[[Sirius Mods]]</var> Version 7.2, the <var>[[HttpRequest]]</var> class had methods only for HTTP GETs and POSTs.  The <var>Send</var> method is the only way to carry out HTTP methods other than GET or POST.
([[Notation conventions for methods#Named parameters|name required]]) parameter.
If the Method value is <code>GET</code> or <code>POST</code>,
the <var>Send</var> method invocation becomes equivalent to the <var>[[Get (HttpRequest function)|Get]]</var>
or [[Post (HttpRequest function)|Post]] method.


Prior to the addition of the Send method in <var class="product">Sirius Mods</var> 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==
==Syntax==
{{Template:HttpRequest:Send syntax}}
{{Template:HttpRequest:Send syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%httpresp</th>
<tr><th>%httpresponse</th>
<td>A reference to the HTTPResponse object instantiated and returned by this Send method.
<td>A reference to the <var>[[HTTPResponse]]</var> object instantiated and returned by this <var>Send</var> method.
</td></tr>
</td></tr>
<tr><th>%httpreq</th>
<tr><th>httpRequest</th>
<td>An instantiated <var>HttpRequest</var> object that contains the request (its methods were used to create the request).
<td>An instantiated <var>HttpRequest</var> object that contains the request (its methods were used to create the request).
</td></tr>
</td></tr>
<tr><th><var>Port=name</var></th>
<tr><th>Port</th>
<td>A string expression that identifies a previously defined Janus CLSOCK port. The ''name'' default is the <var>[[MASTER]]</var> port, if any is defined. However, if you omit ''name'' and no <var>MASTER</var> port is defined, the request is cancelled.
<td>A string expression that identifies a previously defined <var>CLSOCK</var> port. The ''name'' default is the [[MASTER]] port, if any is defined. However, if you omit ''name'' and no <var>MASTER</var> port is defined, the request is canceled.
This argument is optional, but if you specify a value, the parameter name, <var>Port</var> (case not important), is [[Notation conventions for methods#Named parameters|allowed]] as a qualifier.
This is an optional and (as of <var class="product">[[Sirius Mods]]</var> version 7.2) [[Notation conventions for methods#Named parameters|name-allowed]] parameter.  If you specify a value, you may (but don't have to) specify the parameter name, <var>Port</var> (case not important) if you wish.
</td></tr>
</td></tr>
<tr><th><var>Cancel=num</var></th>
<tr><th>Cancel</th>
<td>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.
<td>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 "Usage notes," below, for further discussion of error handling.
This argument is optional, but if you specify a value, the parameter name, <var>Cancel</var> (case not important), is allowed as a qualifier.
This is an optional and (as of <var class="product">Sirius Mods</var> version 7.2) name-allowed parameter.  If you specify a value, you may (but don't have to) specify the parameter name, <var>Cancel</var> (case not important) if you wish.
</td></tr>
</td></tr>
<tr><th><var>Method=methodname</var></th>
<tr><th>Method</th>
<td>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.
<td><var class="term>Method</var> is both a required and <var>[[Methods#Named parameters|Name-Required]]</var> parameter specifying the quoted name of any HTTP method type (for example, 'GET', 'PUT', 'MOVE').
This argument is required, and the parameter name, <var>Method</var> (case not important), is a required qualifier.
The <var class="term>Method</var> name is not case sensitive, but must be supplied; while the method <i>string</i> must be less than or equal to 16 characters long, all uppercase.
</td></tr>
</table>


</td></tr></table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Although you may specify the <var>Method</var> parameter before the optional
<li>Although you may specify the <var class="term>Method</var> 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.
parameters, you receive a compilation error if you do so without
<li>For information about error handling, see the <var>Get</var> function [[Get (HttpRequest function)#Usage notes|"Usage notes"]].
also specifying the optional parameter names with the optional parameters.
<li>To send an HTTP GET or POST, you can also use the <var>[[Get (HttpRequest function)|Get]]</var> method or the <var>[[Post (HttpRequest function)|Post]]</var> method, respectively.
<li>For information
about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.
<li>For information about error handling, see, for example, the <var>Get</var> function
[[Get (HttpRequest function)#Usage notes|"Usage notes"]].
<li>To send an HTTP GET or POST, you can also use the <var>[[Get (HttpRequest function)|Get]]</var> method
or the <var>[[Post (HttpRequest function)|Post]]</var> method, respectively.
</ul>
</ul>
==Examples==
==Examples==
 
<ol>
<li>
<var>Send</var> statements with argument variations are shown below:
<var>Send</var> statements with argument variations are shown below:
<p class="code"> %resp = %req:send(method='DELETE')
<p class="code"> %resp = %req:send(method='DELETE')
Line 59: Line 47:
  %resp = %req:send(method='POST', port='CLPORT', cancel=1)
  %resp = %req:send(method='POST', port='CLPORT', cancel=1)
</p>
</p>
</ol>
==See also==
==See also==
<ul>
<li>For information about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.
</ul>
{{Template:HttpRequest:Send footer}}
{{Template:HttpRequest:Send footer}}

Revision as of 04:45, 19 June 2011

Send an HTTP request to the server (HttpRequest class)

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

%httpResponse = httpRequest:Send( [[Port=] string], [[Cancel=] number], - [CertificateCheck= certificateChecker], - [CheckKeepAliveCertificate= boolean], - Method= name)

Syntax terms

%httpresponse A reference to the HTTPResponse object instantiated and returned by this Send method.
httpRequest An instantiated HttpRequest object that contains the request (its methods were used to create the request).
Port A string expression that identifies a previously defined 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 canceled.

This is an optional and (as of Sirius Mods version 7.2) name-allowed parameter. If you specify a value, you may (but don't have to) specify the parameter name, Port (case not important) if you wish.

Cancel 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 "Usage notes," below, for further discussion of error handling.

This is an optional and (as of Sirius Mods version 7.2) name-allowed parameter. If you specify a value, you may (but don't have to) specify the parameter name, Cancel (case not important) if you wish.

Method Method is both a required and Name-Required parameter specifying the quoted name of any HTTP method type (for example, 'GET', 'PUT', 'MOVE').

The Method name is not case sensitive, but must be supplied; while the method string must be less than or equal to 16 characters long, all uppercase.

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 error handling, see 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

  1. 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