$Web Type: 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 response content type<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Set response content type<section end="desc" /></span>


$Web_Type sets the content type for the response.


$Web_Type sets the content type for the response.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RC = $Web_Type( type )
<p class="syntax"><section begin="syntax" /> %RC = $Web_Type( type )
<section end="syntax" /></p>
<section end="syntax" /></p>


$Web_Type is a callable $function (see [[Calling_Sirius_Mods_$functions|Calling Sirius Mods $functions]]), and it takes a single required string argument and returns a status code.


$Web_Type is a callable $function (see [[Calling_Sirius_Mods_$functions|Calling Sirius Mods $functions]]), and it takes a single required string argument and returns a status code.
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>type</th>
<tr><th>type</th>
Line 25: Line 24:
<tr><th>-4</th>
<tr><th>-4</th>
<td>Missing argument</td></tr>
<td>Missing argument</td></tr>
</table>
</table>
<p class="caption">$WEB_TYPE return codes</p>
<p class="caption">$WEB_TYPE return codes</p>


Sample code follows:
Sample code follows:
<p class="code"> %X = $Web_Type('image/gif')
<p class="code"> %X = $Web_Type('image/gif')
</p>
</p>


The above line sets the content type to CompuServe GIF format (a binary image).<blockquote> You can also set the content type for all output presented in response to a given URL or pattern, if it is not already set, by using the<tt>TYPE</tt> subcommand of the JANUS WEB command, as described in . In this case, a $Web_Type call would not be needed unless the type was being changed from that default.</blockquote>  
The above line sets the content type to CompuServe GIF format (a binary image).<blockquote> You can also set the content type for all output presented in response to a given URL or pattern, if it is not already set, by using the<tt>TYPE</tt> subcommand of the JANUS WEB command, as described in . In this case, a $Web_Type call would not be needed unless the type was being changed from that default.</blockquote>  

Revision as of 15:42, 23 February 2011

<section begin="desc" />Set response content type<section end="desc" />

$Web_Type sets the content type for the response.

Syntax

<section begin="syntax" /> %RC = $Web_Type( type ) <section end="syntax" />

$Web_Type is a callable $function (see Calling Sirius Mods $functions), and it takes a single required string argument and returns a status code.

type The content type indicator. It must be non-null. Janus Web Server makes no assumptions about what a valid type is, and it will set content type to any user-specified string. The HTTP specification (browsable at http://www.w3.org) states that content type should be case insensitive.
Code Meaning
0 Content type set
-1 Invalid call, not a Web thread
-4 Missing argument

$WEB_TYPE return codes

Sample code follows:

%X = $Web_Type('image/gif')

The above line sets the content type to CompuServe GIF format (a binary image).

You can also set the content type for all output presented in response to a given URL or pattern, if it is not already set, by using theTYPE subcommand of the JANUS WEB command, as described in . In this case, a $Web_Type call would not be needed unless the type was being changed from that default.

See also $Web_Output_Type.