Get (HttpRequest function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎See also: add links)
 
(35 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Template:HTTPRequest:Get subtitle}}
{{Template:HttpRequest:Get subtitle}}
The <var>Get</var> method sends an HTTP request to an HTTP server in the HTTP GET format: the request syntax sent to the server is the same as if a <code>METHOD="GET"</code> HTML form was submitted from a web browser, or as if a URL was simply clicked.


The Get method sends an HTTP request to an HTTP server in the HTTP GET format:
the request syntax sent to the server is the same as if a METHOD="GET" HTML form
was submitted from a web browser, or as if a URL was simply clicked.
==Syntax==
==Syntax==
{{Template:HTTPRequest:Get syntax}}
{{Template:HttpRequest:Get 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 Get method.
<td>A reference to the <var>HTTPResponse</var> object instantiated and returned by this <var>Get</var> method.
</td></tr>
</td></tr>
<tr><th>%httpreq</th>
 
<td>The previously defined and instantiated HTTPRequest object that contains the request (its methods were used to create the request).
<tr><th>httpRequest</th>
<td>The previously defined and instantiated <var>HttpRequest</var> object that contains the request (its methods were used to create the request).
</td></tr>
</td></tr>
<tr><th>Port</th>
 
<td>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.
<tr><th><var>Port</var></th>
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, as of <var class="product">Sirius Mods</var> version 7.2.  
<td>A string expression that identifies a previously defined <var>[[JANUS CLSOCK|CLSOCK]]</var> port. The <var class="term">string</var> default is the <var>[[MASTER]]</var> port, if any is defined. If you omit <var class="term">string</var> and no <var>MASTER</var> port is defined, the request is canceled.
This is an optional and [[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).
</td></tr>
 
<tr><th><var>Cancel</var></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 "Usage notes," below, for further discussion of error handling.
This is an optional and 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 want.
</td></tr>
</td></tr>
<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 &amp;amp;ldquo;Usage notes,&amp;amp;rdquo; 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, as of <var class="product">Sirius Mods</var> version 7.2.


<tr><th><var>CertificateCheck</var></th>
<td>This optional ([[Notation conventions for methods#Named parameters|name required]]) argument invokes an SSL certificate request from the server at the time of the method call.
The argument value (<var class="term">certificateChecker</var>) must be a function, presumably [[Local and Common entities#Defining and invoking a local method|local]], with this [[Method variables#Method template in method variable declaration|method template]]:           
<p class="syntax"><span class="literal">Function (String):</span><span class="term">methname</span> <span class="literal">Is Boolean</span> </p>                                   
<p>
When a connection is established, the passed function is called with the certificate (binary content, ASN.1 encoded, copied to a <var>Longstring</var>) as its method object. </p>
<ul>
<li>If the function returns a <code>True</code>, the request is completed. </li>
<li>If the function returns a <code>False</code>, the connection is closed and <var>HttpRequest</var> returns a null.
In this case, the request is canceled unless the <var>Cancel</var> argument setting prevents it. </li>
</ul>
<p>
For a <var>CertificateCheck</var> function example, see [[#Examples|Examples]]. </p></td></tr>
<tr><th><var>CheckKeepAliveCertificate</var></th>
<td>This optional, name required, argument controls how frequently a specified <var>CertificateCheck</var> function is invoked for a an HTTP [[HTTP Helper#Keep-Alive support|keep-alive]] connection. If <code>False</code>, the default, the <var class="term">certificateChecker</var> function is called only when the physical connection is first established and not for every HTTP request on that connection. If set to <code>True</code>, the <var>CertificateCheck</var> method is called for every request, keep-alive or not. 
</td></tr></table>
</td></tr></table>


Line 28: Line 48:
<li>Two classes of non-application errors can occur when <var>Get</var> is invoked:
<li>Two classes of non-application errors can occur when <var>Get</var> is invoked:
<ul>
<ul>
<li>The HTTP request completed, but the server indicated a failure of the request
<li>The HTTP request completed, but the server indicated a failure of the request (an HTTP return code of 400 or greater). An example of this is the "404 not found" message issued by a web server when a
(an HTTP return code of 400 or greater).
non-existent document is referenced. In this class of error, there was no TCP/IP communication error.
An example of this is the "404 not found" message issued by a web server when a
non-existent document is referenced.
In this class of error, there was no TCP/IP communication error.


For these errors, the request is never cancelled, and an <var>[[HTTPResponse class|HTTPResponse]]</var> object
For these errors, the request is never cancelled, and an <var>[[HttpResponse class|HttpResponse]]</var> object is always returned. The application handles these errors by [[HttpResponse class#Status reporting|checking]] the <var>HTTPResponse</var> <var>[[Code_(HttpResponse_function)|Code]]</var>, <var>[[StatusLine_(HttpResponse_function)|StatusLine]]</var>, <var>[[Message_(HttpResponse_function)|Message]]</var>, and <var>[[Success_(HttpResponse_function)|Success]]</var> methods.
is always returned.
<li>While attempting the HTTP request, a socket/communication error occurred. Examples of such errors include failure to connect to the server host, and communication failure on a TCP/IP send or receive.
The application handles these errors by [[The HTTPResponse methods#Status reporting|checking]] the
<var>HTTPResponse</var>
<var>Code</var>, <var>StatusLine</var>, <var>Message</var>, and <var>Success</var> methods.
<li>While attempting the HTTP request, a socket/communication error occurred.
Examples of such errors include failure to connect to the server host, and
communication failure on a TCP/IP send or receive.


For this class of errors, no instance of <var>HTTPResponse</var> is created, and
For this class of errors, no instance of <var>HTTPResponse</var> is created, and a <var>Null</var> object is returned. In addition, $Status is set to 1, and $StatusD is set to one of these:
a <var>Null</var> object is returned.
In addition, $STATUS is set to 1, and $STATUSD is set to one of these:
<ul>
<ul>
<li>A negative return code that indicates an error in connecting to the
<li>A negative return code that indicates an error in connecting to the target HTTP server. These codes are shown below in [[#Get method return values|Get method return values]]. </li>
target HTTP server.
 
These codes are shown below in [[#Get method return values|"Get method return values"]].
<li>A positive return code indicating a communications error after the connection was made. </li>
<li>A positive return code indicating a communications error after
the connection was made.
</ul>
</ul>
The request may or may not be cancelled based on the setting of
The request may or may not be cancelled based on the setting of the <var>Cancel</var> parameter.
the ''cancel'' parameter.
<p>
Some of these errors are relatively benign (for example, inability to connect because remote partner down, timeout value exceeded), so they produce information-only messages, and they are treated as non-counting.  These errors can still be detected and handled by the application (by checking for a <var>Null</var> result object, checking <var>[[$Status]]</var> and <var>[[$StatusD]]</var>, or both). </p>


Some of these errors are relatively benign (for example, inability to connect
<blockquote class="note">'''Note:''' The distinctions between some of the return codes might or might not be meaningful, depending on the situation. For example, network problems can cause a 101 return code (indicating a timeout) or a 102 (indicating a connection closed).  Connecting to a server that is using a non-HTTP protocol can result in a 100 (invalid format data received from the server) or a 101 or 102, depending on the protocol used by the server to which the request is sent: a request sent to a telnet port '''usually''' results in a timeout (return code 101), while a request sent to an SSL port without using <code>https</code> to indicate SSL '''usually''' results in the target server breaking the connection (return code 102).
because remote partner down, timeout value exceeded),
<p>
so they produce information-only messages, and they are treated as non-counting.
In general, it is risky to take action based on the distinction between the various non-zero error codes returned by this method. </p>
These errors can still be detected and handled by the application (by
</blockquote>
checking for a Null result object, checking $STATUS and $STATUSD, or both).
</ul>
<br>'''Note:'''
<p>
The distinctions between some of the return codes might or might not be meaningful,
For more information about an error, you may want to issue a <var>[[JANUS TRACE]]</var> command with a value of 8 or 15 for the <var>CLSOCK</var> port that is handling your HTTP request. </p>
depending on the situation.


For example, network problems can cause a 101 return code (indicating
<li>Under <var class="product">Sirius Mods</var> versions before 7.1, certain "post-oriented" actions were not allowed with an HTTP GET, and resulted in request cancellation if detected by <var>Get</var> function error checking:
a timeout) or a 102 (indicating a connection closed).
<ul>
Connecting to a server that is using a non-HTTP protocol can result in a
<li>An <var>[[AddXml (HttpRequest subroutine)|AddXml]]</var> call added Post data to the request. </li>
100 (invalid format data received from the server) or a 101 or 102,
depending on the protocol used by the server to which the request is sent:
a request sent to a telnet port '''usually''' results in a
timeout (return code 101), while a request sent to an SSL port without using
<code>https</code> to indicate SSL '''usually''' results in the target
server breaking the connection (return code 102).


In general, it is risky to take action based on the
<li>An <var>[[AddLongstring (HttpRequest subroutine)|AddLongstring]]</var> call added Post data to the request. </li>
distinction between the various non-zero error codes returned by this method.
 
<li>The <var>[[MultiPartFormEncoding (HttpRequest property)|MultiPartFormEncoding]]</var> property set to <code>True</code> enabled multipart form encoding. </li>
</ul>
</ul>
<p>
Under <var class="product">Sirius Mods</var> 7.1 and later, these methods are allowed before a <var>Get</var> method call.  While unusual, passing content in a <var>Get</var> method is not strictly forbidden by the HTTP specification.</p></li>


For more information about an error, you may want to
<li>For HTTP Version 1.1 mode only, the HTTP request header "connection: close" is automatically sent on GETs and POSTs to ensure that the server closes the connection with the client when the HTTP request completes.
issue a <var>[[JANUS TRACE command|JANUS TRACE]]</var> command with a value of 8 or 15
The <var class="product">HTTP Helper</var> does '''not''' support persistent connections. </li>
for the <var>CLSOCK</var> port that is handling your HTTP request.


For more information about $STATUS and $STATUSD, see the <var class="product">Model 204</var>
<li>If the ports associated with the sockets in the HTTP request are not using SSL, and the <var>CertificateCheck</var> argument is specified, the <var class="term">certificateChecker</var> function does not get called. </li>
<i>User Language Manual</i>.
<li>Under <var class="product">Sirius Mods</var> versions before 7.1, certain
&amp;amp;ldquo;post-oriented&amp;amp;rdquo; actions were not allowed with an HTTP GET, and
resulted in request cancellation if detected by <var>Get</var> function error checking:
<ul>
<li>An <var>AddXML</var> call added Post data to the request.
<li>An <var>AddLongString</var> call added Post data to the request.
<li>The <var>MultiPartFormEncoding</var> property set to <code>True</code> enabled
multipart form encoding.
</ul>


Under <var class="product">Sirius Mods</var> 7.1 and later, these methods are allowed before a <var>Get</var>
<li>For more information about the HTTP GET request format and about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.
method call.
</li>
While unusual, passing content in a <var>Get</var> method is not strictly forbidden
by the HTTP specification.
<li>For HTTP Version 1.1 mode only,
the HTTP request header &amp;amp;ldquo;connection: close&amp;amp;rdquo; is automatically
sent on GETs and POSTs to ensure that the server closes the
connection with the client when the HTTP request completes.
The <var class="product">HTTP Helper</var> does '''not''' support persistent connections.
<li>For more information about the HTTP GET request format and
about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.
<li>You can also send an HTTP GET using the <var>[[Send (HTTPRequest function)|Send]]</var> method.
</ul>
</ul>


==Get method return values==  
==Get method return values==  
<table>
<table>
<tr><th>Code</th><th>Meaning</th></tr>
<tr class="head"><th>Code</th><th>Meaning</th></tr>
<tr><td>0</td>
<tr><td>0</td>
<td>Communications was successful.</td></tr>  
<td>Communications was successful.</td></tr>
<tr><td>100</td> <td>The format of the response from the server was invalid.</td></tr>  
 
<tr><td>101</td> <td>A <var>Get</var> operation exceeded its [[Timeout (HTTPRequest property)|timeout]] value.</td></tr> <tr><td>102</td> <td>The connection was closed before the complete response was received.</td></tr>  
<tr><td>100</td>  
<tr><td>-100</td> <td>No free socket numbers for user.</td></tr>  
<td>The format of the response from the server was invalid.</td></tr>
<tr><td>-101</td> <td>Remote host name or IP address missing or mismatch with <var>CLSOCK</var> port definition.</td></tr> <tr><td>-102</td> <td>Remote port number missing or mismatch with <var>CLSOCK</var> port definition.</td></tr>  
 
<tr><td>-103</td> <td><var>CLSOCK</var> port not defined or not started.</td></tr>  
<tr><td>101</td>  
<tr><td>-104</td> <td>All ports on specified <var>CLSOCK</var> port are busy.</td></tr>  
<td>A <var>Get</var> operation exceeded its [[Timeout (HttpRequest property)|timeout]] value.</td></tr>
<tr><td>-105</td> <td>Insufficient virtual storage.</td></tr>  
 
<tr><td>-106</td> <td>Maximum connections exceeded.</td></tr>  
<tr><td>102</td>  
<tr><td>-107</td> <td>Couldn't resolve remote host.</td></tr>  
<td>The connection was closed before the complete response was received.</td></tr>
<tr><td>-108</td> <td>Remote port not responding.</td></tr>  
 
<tr><td>-109</td> <td>Already have <var>[[SOCKPMAX]]</var> sockets open on this <var>CLSOCK</var> port.</td></tr>  
<tr><td>-100</td>  
<tr><td>-110</td> <td>SSL/NOSSL setting mismatch.</td></tr>  
<td>No free socket numbers for user.</td></tr>
<tr><td>-111</td> <td>SSL handshake error.</td></tr>  
 
<tr><td>-112</td> <td>Access to <var>CLSOCK</var> port not enabled by ALLOW rule.</td></tr> </table>
<tr><td>-101</td>  
<td>Remote host name or IP address missing or mismatch with <var>CLSOCK</var> port definition.</td></tr>
 
<tr><td>-102</td>  
<td>Remote port number missing or mismatch with <var>CLSOCK</var> port definition.</td></tr>
 
<tr><td>-103</td>  
<td><var>CLSOCK</var> port not defined or not started.</td></tr>
 
<tr><td>-104</td>  
<td>All ports on specified <var>CLSOCK</var> port are busy.</td></tr>
 
<tr><td>-105</td>  
<td>Insufficient virtual storage.</td></tr>
 
<tr><td>-106</td>  
<td>Maximum connections exceeded.</td></tr>
 
<tr><td>-107</td>  
<td>Couldn't resolve remote host.</td></tr>
 
<tr><td>-108</td>  
<td>Remote port not responding.</td></tr>
 
<tr><td>-109</td>  
<td>Already have <var>[[SOCKPMAX]]</var> sockets open on this <var>CLSOCK</var> port.</td></tr>
 
<tr><td>-110</td>  
<td>SSL/NOSSL setting mismatch.</td></tr>
 
<tr><td>-111</td>  
<td>SSL handshake error.</td></tr>
 
<tr><td>-112</td>  
<td>Access to <var>CLSOCK</var> port not enabled by <var>[[JANUS WEB ALLOW|ALLOW]]</var> rule.</td></tr>
 
<tr><td>-149</td>
<td>Other error during connection attempt which prevents establishment of the connection. </td></tr>
</table>
 
==Examples==
In this code fragment, the <var>CertificateCheck</var> argument of <var>Get</var> invokes a local method that displays some       
information about the client socket's SSL certificate. The local method returns a <code>True</code> enumeration value to the <var>Get</var>, and the request continues:
<p class="code">local function (string):foo is boolean 
printText {~=%this:length}                               
printText {%this:stringToHex}                             
printText {%this:asciiToEbcdic(characterEncode=true)}     
return true
 
end function
  ...
%req  is object httpRequest
%resp  is object httpResponse
  ...
%resp = %req:get(certificateCheck=foo, checkKeepAliveCertificate=true)
  ...  </p>
<div id="exception-eg"></div>
<p>
This variation of the preceding example shows that the <var class="term">certificateChecker</var> function (<code>foo</code>) may contain code to throw an exception:
</p>
<p class="code">class badCert Exception
...
end class
...
local function (string):foo is boolean throws badCert   
  printText {~=%this:length}
  printText {%this:stringToHex}
  printText {%this:asciiToEbcdic(characterEncode=true)}
  return true
 
  %bad is object badCert
  if ...
    throw %bad
  end if
end function
  ...
%req  is object httpRequest
%resp  is object httpResponse
  ...
try %resp = %req:get(certificateCheck=foo, checkKeepAliveCertificate=true)
catch badCert
  printText Caught a bad certificate
  stop   
end try
  ...  </p>
 
==See also==
==See also==
{{Template:HTTPRequest:Get footer}}
<ul>
<li>You can also send an HTTP GET using the <var>[[Send (HttpRequest function)|Send]]</var> method. </li>
 
<li>For methods that work with SSL certificates, for example letting you access certificate information, see <var>[[AppendCertificateInfo (Stringlist function)|AppendCertificateInfo]]</var> and its related <var>Stringlist</var> methods, or see <var>[[X509CertificateToXmlDoc (String function)|X509CertificateToXmlDoc]]</var> and its related <var>String</var> methods.
</ul>
 
{{Template:HttpRequest:Get footer}}

Latest revision as of 00:10, 16 March 2016

Send an HTTP GET request to the server (HttpRequest class)

The Get method sends an HTTP request to an HTTP server in the HTTP GET format: the request syntax sent to the server is the same as if a METHOD="GET" HTML form was submitted from a web browser, or as if a URL was simply clicked.

Syntax

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

Syntax terms

%httpResponse A reference to the HTTPResponse object instantiated and returned by this Get method.
httpRequest The previously defined and 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 string default is the MASTER port, if any is defined. If you omit string and no MASTER port is defined, the request is canceled.

This is an optional and name allowed parameter. If you specify a value, you may (but don't have to) specify the parameter name, Port (case not important).

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

CertificateCheck This optional (name required) argument invokes an SSL certificate request from the server at the time of the method call.

The argument value (certificateChecker) must be a function, presumably local, with this method template:

Function (String):methname Is Boolean

When a connection is established, the passed function is called with the certificate (binary content, ASN.1 encoded, copied to a Longstring) as its method object.

  • If the function returns a True, the request is completed.
  • If the function returns a False, the connection is closed and HttpRequest returns a null. In this case, the request is canceled unless the Cancel argument setting prevents it.

For a CertificateCheck function example, see Examples.

CheckKeepAliveCertificate This optional, name required, argument controls how frequently a specified CertificateCheck function is invoked for a an HTTP keep-alive connection. If False, the default, the certificateChecker function is called only when the physical connection is first established and not for every HTTP request on that connection. If set to True, the CertificateCheck method is called for every request, keep-alive or not.

Usage notes

  • Two classes of non-application errors can occur when Get is invoked:
    • The HTTP request completed, but the server indicated a failure of the request (an HTTP return code of 400 or greater). An example of this is the "404 not found" message issued by a web server when a non-existent document is referenced. In this class of error, there was no TCP/IP communication error. For these errors, the request is never cancelled, and an HttpResponse object is always returned. The application handles these errors by checking the HTTPResponse Code, StatusLine, Message, and Success methods.
    • While attempting the HTTP request, a socket/communication error occurred. Examples of such errors include failure to connect to the server host, and communication failure on a TCP/IP send or receive. For this class of errors, no instance of HTTPResponse is created, and a Null object is returned. In addition, $Status is set to 1, and $StatusD is set to one of these:
      • A negative return code that indicates an error in connecting to the target HTTP server. These codes are shown below in Get method return values.
      • A positive return code indicating a communications error after the connection was made.

      The request may or may not be cancelled based on the setting of the Cancel parameter.

      Some of these errors are relatively benign (for example, inability to connect because remote partner down, timeout value exceeded), so they produce information-only messages, and they are treated as non-counting. These errors can still be detected and handled by the application (by checking for a Null result object, checking $Status and $StatusD, or both).

      Note: The distinctions between some of the return codes might or might not be meaningful, depending on the situation. For example, network problems can cause a 101 return code (indicating a timeout) or a 102 (indicating a connection closed). Connecting to a server that is using a non-HTTP protocol can result in a 100 (invalid format data received from the server) or a 101 or 102, depending on the protocol used by the server to which the request is sent: a request sent to a telnet port usually results in a timeout (return code 101), while a request sent to an SSL port without using https to indicate SSL usually results in the target server breaking the connection (return code 102).

      In general, it is risky to take action based on the distinction between the various non-zero error codes returned by this method.

    For more information about an error, you may want to issue a JANUS TRACE command with a value of 8 or 15 for the CLSOCK port that is handling your HTTP request.

  • Under Sirius Mods versions before 7.1, certain "post-oriented" actions were not allowed with an HTTP GET, and resulted in request cancellation if detected by Get function error checking:

    Under Sirius Mods 7.1 and later, these methods are allowed before a Get method call. While unusual, passing content in a Get method is not strictly forbidden by the HTTP specification.

  • For HTTP Version 1.1 mode only, the HTTP request header "connection: close" is automatically sent on GETs and POSTs to ensure that the server closes the connection with the client when the HTTP request completes. The HTTP Helper does not support persistent connections.
  • If the ports associated with the sockets in the HTTP request are not using SSL, and the CertificateCheck argument is specified, the certificateChecker function does not get called.
  • For more information about the HTTP GET request format and about the HTTP protocol, refer to http://www.w3.org/Protocols/rfc2616/rfc2616.html.

Get method return values

CodeMeaning
0 Communications was successful.
100 The format of the response from the server was invalid.
101 A Get operation exceeded its timeout value.
102 The connection was closed before the complete response was received.
-100 No free socket numbers for user.
-101 Remote host name or IP address missing or mismatch with CLSOCK port definition.
-102 Remote port number missing or mismatch with CLSOCK port definition.
-103 CLSOCK port not defined or not started.
-104 All ports on specified CLSOCK port are busy.
-105 Insufficient virtual storage.
-106 Maximum connections exceeded.
-107 Couldn't resolve remote host.
-108 Remote port not responding.
-109 Already have SOCKPMAX sockets open on this CLSOCK port.
-110 SSL/NOSSL setting mismatch.
-111 SSL handshake error.
-112 Access to CLSOCK port not enabled by ALLOW rule.
-149 Other error during connection attempt which prevents establishment of the connection.

Examples

In this code fragment, the CertificateCheck argument of Get invokes a local method that displays some information about the client socket's SSL certificate. The local method returns a True enumeration value to the Get, and the request continues:

local function (string):foo is boolean printText {~=%this:length} printText {%this:stringToHex} printText {%this:asciiToEbcdic(characterEncode=true)} return true end function ... %req is object httpRequest %resp is object httpResponse ... %resp = %req:get(certificateCheck=foo, checkKeepAliveCertificate=true) ...

This variation of the preceding example shows that the certificateChecker function (foo) may contain code to throw an exception:

class badCert Exception ... end class ... local function (string):foo is boolean throws badCert printText {~=%this:length} printText {%this:stringToHex} printText {%this:asciiToEbcdic(characterEncode=true)} return true %bad is object badCert if ... throw %bad end if end function ... %req is object httpRequest %resp is object httpResponse ... try %resp = %req:get(certificateCheck=foo, checkKeepAliveCertificate=true) catch badCert printText Caught a bad certificate stop end try ...

See also

  • You can also send an HTTP GET using the Send method.
  • For methods that work with SSL certificates, for example letting you access certificate information, see AppendCertificateInfo and its related Stringlist methods, or see X509CertificateToXmlDoc and its related String methods.