$Web Response: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (misc formatting) |
||
(18 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$Web_Response}} | {{DISPLAYTITLE:$Web_Response}} | ||
<span class="pageSubtitle" | <span class="pageSubtitle">Set HTTP response header parameter</span> | ||
<var>$Web_Response</var> can be used to set any HTTP response header parameter. | |||
<var>$Web_Response</var> is a [[Calling_Sirius_Mods_$functions|callable]] $function, and it takes two arguments and returns a numeric status code. | |||
==Syntax== | ==Syntax== | ||
<p class="syntax">< | <p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Response</span>(<span class="term"> parameter</span>, <span class="term">value</span> ) | ||
< | </p> | ||
< | |||
< | |||
</ | |||
<table | ===Syntax terms=== | ||
<tr><th> | <table> | ||
<td> | <tr><th>%rc</th> | ||
<td>A numeric variable to contain a return code. Possible values are: | |||
<table class="thJustBold"> | |||
<tr><th>0</th> | <tr><th>0</th> | ||
<td>Response header parameter set.</td></tr> | <td>Response header parameter set.</td></tr> | ||
<tr><th>-1</th> | <tr><th>-1</th> | ||
<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></td></tr> | |||
<tr><th>parameter</th> | |||
<td>A <var>String</var> (or <var>[[Longstrings|Longstring]]</var> if Model 204 7.7 or higher) containing the name of the HTTP response header parameter.</td></tr> | |||
<tr><th>value</th> | |||
<td>A <var>String</var> (or <var>Longstring</var> if Model 204 7.7 or higher) containing the value of the HTTP response header parameter. | |||
</td></tr> | |||
</table> | </table> | ||
==Usage notes== | |||
<ul> | |||
<li>Most response header parameters are set "under-the-covers" automatically or as the result of other <var class="product">[[Janus Web Server]]</var> $function calls. These automatically-set parameters should be adequate for most applications. In the cases where they're not, <var>$Web_Response</var> provides the ability to set response header parameters directly. | |||
<p> | |||
The response header parameter that is most likely to be useful and that can only be set with <var>$Web_Response</var> 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:</p> | |||
<p class="code">%rc = $Web_Response('Pragma', 'no-cache') | |||
</p></li> | |||
<li>The response header parameters are not sent until the size of the response has been determined, as the result of a <var>$Web_Done</var> or a <var>$Web_ProcSend</var>. Until one of these is issued, it is possible to change the value of a response header parameter at will. </li> | |||
< | |||
The response header parameters are not sent until the size of the response has been determined, | |||
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 | <li><b>Attention:</b> Extreme caution should be used with this function since it provides direct access to the HTTP layer of the web protocols. <var>$Web_Response</var> does '''no''' validity checking for the parameter name or value specified. For more information about the HTTP standard response header parameters, visit https://en.wikipedia.org/wiki/List_of_HTTP_header_fields and http://www.iana.org/assignments/message-headers/message-headers.xml#perm-headers. </li> | ||
[[Category:Janus Web Server $functions|$Web_Response]] | [[Category:Janus Web Server $functions|$Web_Response]] |
Latest revision as of 23:38, 5 July 2016
Set HTTP response header parameter
$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
%rc = $Web_Response( parameter, value )
Syntax terms
%rc | A numeric variable to contain a return code. Possible values are:
| ||||||
---|---|---|---|---|---|---|---|
parameter | A String (or Longstring if Model 204 7.7 or higher) containing the name of the HTTP response header parameter. | ||||||
value | A String (or Longstring if Model 204 7.7 or higher) containing the value of the HTTP response header parameter. |
Usage notes
- Most response header parameters are set "under-the-covers" 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, 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.
- Attention: 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 standard response header parameters, visit https://en.wikipedia.org/wiki/List_of_HTTP_header_fields and http://www.iana.org/assignments/message-headers/message-headers.xml#perm-headers.