$Web Response: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 2: Line 2:
<span class="pageSubtitle"><section begin="desc" />Set HTTP response header parameter<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Set HTTP response header parameter<section end="desc" /></span>


$Web_Response can be used to set any HTTP response header parameter.


$Web_Response is a [[Calling_Sirius_Mods_$functions|callable]] $function, and it takes two arguments and returns a numeric status code.


$Web_Response can be used to set any HTTP response header parameter.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RC = $Web_Response( parameter, value )
<p class="syntax"><section begin="syntax" /> %RC = $Web_Response( parameter, value )
<section end="syntax" /></p>
<section end="syntax" /></p>


 
===Syntax terms===
$Web_Response is a callable $function (see [[Calling_Sirius_Mods_$functions|Calling Sirius Mods $functions]]), and it takes two arguments and returns a numeric status code.
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>parameter</th>
<tr><th>%rc</th>
<td>The name of the HTTP response header parameter.</td></tr>
<td>A numeric variable to contain a return code. Possible values are:
<tr><th>value</th>
<td>The value of the HTTP response header parameter.
</td></tr></table>
 
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>Code</th>
<td>Meaning</td></tr>
<tr><th>0</th>
<tr><th>0</th>
<td>Response header parameter set.</td></tr>
<td>Response header parameter set.</td></tr>
Line 26: Line 20:
<td>Not a web thread</td></tr>
<td>Not a web thread</td></tr>
<tr><th>-5</th>
<tr><th>-5</th>
<td>Parameter name missing.</td></tr>
<td>Parameter name missing.</td></tr></table>
 
</table>
<p class="caption">$WEB_RESPONSE return codes</p>


<tr><th>parameter</th>
<td>The name of the HTTP response header parameter.</td></tr>
<tr><th>value</th>
<td>The value of the HTTP response header parameter.
</td></tr></table>


==Usage notes==
Most response header parameters are set "under-the-covers" either automatically or as the result of other ''[[Janus Web Server]]'' $function calls. These automatically set parameters should be adequate for most applications. In the cases where they're not, $Web_Response provides the ability to set response header parameters directly.
Most response header parameters are set "under-the-covers" either automatically or as the result of other ''[[Janus Web Server]]'' $function calls. These automatically set parameters should be adequate for most applications. In the cases where they're not, $Web_Response provides the ability to set response header parameters directly.
The response header parameter that is most likely to be useful and that can only be set with $Web_Response is the "Pragma" parameter which can be used to indicate that a response should not be cached by the browser as in the following example.
The response header parameter that is most likely to be useful and that can only be set with $Web_Response is the "Pragma" parameter which can be used to indicate that a response should not be cached by the browser as in the following example.
Line 38: Line 35:
The response header parameters are not sent until the size of the response has been determined, either as the result of a <var>$Web_Done</var> or a $Web_ProcSend. Until one of these is issued, it is possible to change the value of a response header parameter at will.  
The response header parameters are not sent until the size of the response has been determined, either as the result of a <var>$Web_Done</var> or a $Web_ProcSend. Until one of these is issued, it is possible to change the value of a response header parameter at will.  


Extreme caution should be used with this function since it provides direct access to the HTTP layer of the web protocols. $Web_Response does '''no''' validity checking for the parameter name or value specified. For more information about the HTTP protocol including a specification of all the standard response header parameters, visit '''http://www.ics.uci.edu/pub/ietf/http/'''.
Extreme caution should be used with this function since it provides direct access to the HTTP layer of the web protocols. $Web_Response does '''no''' validity checking for the parameter name or value specified. For more information about the HTTP protocol including a specification of all the standard response header parameters, visit http://www.ics.uci.edu/pub/ietf/http/.


[[Category:Janus Web Server $functions|$Web_Response]]
[[Category:Janus Web Server $functions|$Web_Response]]

Revision as of 19:57, 6 June 2012

<section begin="desc" />Set HTTP response header parameter<section end="desc" />

$Web_Response can be used to set any HTTP response header parameter.

$Web_Response is a callable $function, and it takes two arguments and returns a numeric status code.

Syntax

<section begin="syntax" /> %RC = $Web_Response( parameter, value ) <section end="syntax" />

Syntax terms

%rc A numeric variable to contain a return code. Possible values are:
0 Response header parameter set.
-1 Not a web thread
-5 Parameter name missing.
parameter The name of the HTTP response header parameter.
value The value of the HTTP response header parameter.

Usage notes

Most response header parameters are set "under-the-covers" either automatically or as the result of other Janus Web Server $function calls. These automatically set parameters should be adequate for most applications. In the cases where they're not, $Web_Response provides the ability to set response header parameters directly. The response header parameter that is most likely to be useful and that can only be set with $Web_Response is the "Pragma" parameter which can be used to indicate that a response should not be cached by the browser as in the following example.

%RC = $Web_Response('Pragma', 'no-cache')

The response header parameters are not sent until the size of the response has been determined, either as the result of a $Web_Done or a $Web_ProcSend. Until one of these is issued, it is possible to change the value of a response header parameter at will.

Extreme caution should be used with this function since it provides direct access to the HTTP layer of the web protocols. $Web_Response does no validity checking for the parameter name or value specified. For more information about the HTTP protocol including a specification of all the standard response header parameters, visit http://www.ics.uci.edu/pub/ietf/http/.