$Web Type: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Web_Type}}
{{DISPLAYTITLE:$Web_Type}}
<span class="pageSubtitle"><section begin="desc" />Set response content type<section end="desc" /></span>
<span class="pageSubtitle">Set response content type</span>


$Web_Type sets the content type for the response.
<var>$Web_Type</var> sets the content type for the response.
 
<var>$Web_Type</var> is a [[Calling_Sirius_Mods_$functions|callable]] $function, and it takes a single required string argument and returns a status code.


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RC = $Web_Type( type )
<p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Type</span>(<span class="term">type</span>)
<section end="syntax" /></p>
</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.


<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>type</th>
<tr><th>type</th>
<td>The content type indicator. It must be non-null. <var class="product">[[Janus Web Server]]</var> 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.
<td>The content type indicator. It must be non-null. <var class="product">[[Janus Web Server]]</var> 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.
</td></tr></table>
</td></tr></table>


<table class="syntaxTable">
===Status codes===
<table>
<tr><th>Code</th>
<tr><th>Code</th>
<td>Meaning</td></tr>
<th>Meaning</th></tr>
<tr><th>0</th>
<tr><td>0</td>
<td>Content type set</td></tr>
<td>Content type set</td></tr>
<tr><th>-1</th>
<tr><td>-1</td>
<td>Invalid call, not a Web thread</td></tr>
<td>Invalid call, not a Web thread</td></tr>
<tr><th>-4</th>
<tr><td>-4</td>
<td>Missing argument</td></tr>
<td>Missing argument</td></tr>
</table>
</table>
<p class="caption">$WEB_TYPE return codes</p>


==Examples==
Sample code follows:
Sample code follows:
<p class="code"> %X = $Web_Type('image/gif')
<p class="code">%x = $Web_Type('image/gif')
</p>
</p>
<p>
The above line sets the content type to CompuServe GIF format (a binary image). </p>
<p>
'''Note:''' 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 <var>TYPE</var> subcommand of the <var>[[JANUS WEB]]</var> command. In this case, a <var>$Web_Type</var> call would not be needed unless the type was being changed from that default. </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>  
==See also==
 
<ul>
See also [[$Web_Output_Type]].
<li><var>[[$Web_Output_Type]]</var>


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

Latest revision as of 19:57, 12 April 2013

Set response content type

$Web_Type sets the content type for the response.

$Web_Type is a callable $function, and it takes a single required string argument and returns a status code.

Syntax

%rc = $Web_Type(type)

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.

Status codes

Code Meaning
0 Content type set
-1 Invalid call, not a Web thread
-4 Missing argument

Examples

Sample code follows:

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

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

Note: 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 TYPE subcommand of the JANUS WEB command. In this case, a $Web_Type call would not be needed unless the type was being changed from that default.

See also