$Web Done: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Web_Done}}
{{DISPLAYTITLE:$Web_Done}}
<span class="pageSubtitle"><section begin="desc" />Send Web response<section end="desc" /></span>
<span class="pageSubtitle">Send Web response</span>


<var>$Web_Done</var> signals completion of a request.
<var>$Web_Done</var> signals completion of a request.
Line 6: Line 6:


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %rc = $Web_Done( status_code, message )
<p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Done</span>([<span class="term">status_code</span>], [<span class="term">message</span>] )
<section end="syntax" /></p>
</p>


===Syntax terms===
===Syntax terms===
Line 33: Line 33:
<tr><th>200</th>
<tr><th>200</th>
<td>OK</td></tr>
<td>OK</td></tr>
<tr><th>201</th>
<tr><th>201</th>
<td>Created</td></tr>
<td>Created</td></tr>
<tr><th>202</th>
<tr><th>202</th>
<td>Accepted</td></tr>
<td>Accepted</td></tr>
<tr><th>204</th>
<tr><th>204</th>
<td>No Content</td></tr>
<td>No Content</td></tr>
<tr><th>301</th>
<tr><th>301</th>
<td>Moved Permanently</td></tr>
<td>Moved Permanently</td></tr>
<tr><th>302</th>
<tr><th>302</th>
<td>Moved Temporarily</td></tr>
<td>Moved Temporarily</td></tr>
<tr><th>304</th>
<tr><th>304</th>
<td>Not Modified</td></tr>
<td>Not Modified</td></tr>
<tr><th>400</th>
<tr><th>400</th>
<td>Bad Request</td></tr>
<td>Bad Request</td></tr>
<tr><th>401</th>
<tr><th>401</th>
<td>Not Authorized (logon required)</td></tr>
<td>Not Authorized (logon required)</td></tr>
<tr><th>403</th>
<tr><th>403</th>
<td>Forbidden</td></tr>
<td>Forbidden</td></tr>
<tr><th>404</th>
<tr><th>404</th>
<td>Not Found</td></tr>
<td>Not Found</td></tr>
<tr><th>500</th>
<tr><th>500</th>
<td>Internal Server Error</td></tr>
<td>Internal Server Error</td></tr>
<tr><th>501</th>
<tr><th>501</th>
<td>Not Implemented</td></tr>
<td>Not Implemented</td></tr>
<tr><th>502</th>
<tr><th>502</th>
<td>Bad Gateway</td></tr>
<td>Bad Gateway</td></tr>
<tr><th>503</th>
<tr><th>503</th>
<td>Service Unavailable
<td>Service Unavailable
</td></tr></table>
</td></tr>
</table>


==Usage notes==
==Usage notes==
Line 67: Line 82:
<li>Invoking <var>$Web_Done</var> closes the client connection, optionally sending the status code and message text to the user. Once <var>$Web_Done</var> is invoked, the thread may continue processing but no more calls to $Web* functions are allowed, and nothing further may be sent to the client.  
<li>Invoking <var>$Web_Done</var> closes the client connection, optionally sending the status code and message text to the user. Once <var>$Web_Done</var> is invoked, the thread may continue processing but no more calls to $Web* functions are allowed, and nothing further may be sent to the client.  


The connection to the client is also broken by a ''Model 204'' LOGOFF or any return to command level. These are perfectly valid ways of terminating requests. The function of <var>$Web_Done</var> is to send the status code and error message and terminate the connection; hence no further information will be sent to the client.  
The connection to the client is also broken by a <var class="product">Model 204</var> LOGOFF or any return to command level. These are perfectly valid ways of terminating requests. The function of <var>$Web_Done</var> is to send the status code and error message and terminate the connection; hence no further information will be sent to the client.  


<li>Of potential value when monitoring your application, the Sirius statistic JWEBERRS reports the number of times that ''[[Janus Web Server]]'' returned one of the 4xx status codes. Also, the JSCREENS statistic counts the number of times ''Janus Web Server'' incremented the SCREENS statistic. These statistics are available as of ''Sirius Mods'' version 7.6, and they are retrievable or viewable with $SyStat or ''[[SirMon]]''.
<li>Of potential value when monitoring your application, the Sirius statistic JWEBERRS reports the number of times that <var class="product">[[Janus Web Server]]</var> returned one of the 4xx status codes. Also, the JSCREENS statistic counts the number of times ''Janus Web Server'' incremented the SCREENS statistic. These statistics are available as of <var class="product">Sirius Mods</var> version 7.6, and they are retrievable or viewable with $SyStat or ''[[SirMon]]''.
</ul>
</ul>



Latest revision as of 20:40, 12 April 2013

Send Web response

$Web_Done signals completion of a request. This callable $function accepts two optional arguments and returns a numeric result code.

Syntax

%rc = $Web_Done([status_code], [message] )

Syntax terms

%rc A numeric variable to contain either of these return codes:
0 Completed successfully
-1 Not a web thread
status_code Used in many cases for automatic browser error or exception handling, these codes are summarized below.
message Further elucidation of the error. In some cases, displayed verbatim to the browser's user.

Status codes

Status codes and their associated messages are standardized for most Web Servers. The standards are available for browsing in Chapter 9 of the HTTP working draft.

The standard codes are:

200 OK
201 Created
202 Accepted
204 No Content
301 Moved Permanently
302 Moved Temporarily
304 Not Modified
400 Bad Request
401 Not Authorized (logon required)
403 Forbidden
404 Not Found
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable

Usage notes

  • Invoking $Web_Done closes the client connection, optionally sending the status code and message text to the user. Once $Web_Done is invoked, the thread may continue processing but no more calls to $Web* functions are allowed, and nothing further may be sent to the client. The connection to the client is also broken by a Model 204 LOGOFF or any return to command level. These are perfectly valid ways of terminating requests. The function of $Web_Done is to send the status code and error message and terminate the connection; hence no further information will be sent to the client.
  • Of potential value when monitoring your application, the Sirius statistic JWEBERRS reports the number of times that Janus Web Server returned one of the 4xx status codes. Also, the JSCREENS statistic counts the number of times Janus Web Server incremented the SCREENS statistic. These statistics are available as of Sirius Mods version 7.6, and they are retrievable or viewable with $SyStat or SirMon.

Examples

Use $Web_Done in error routines and to sever client connections with custom messages. For example:

SECURE: In AUTHS Fd UID = %user End Find CT_SEC: Count Records In SECURE If Not Count In CT_SEC Then %x = $Web_Done('403','Forbidden') Stop End If