$Web Hdr Parm: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
m (add link)
 
(5 intermediate revisions by 4 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Value of request header field</span>
<span class="pageSubtitle">Value of request header field</span>


__NOTOC__


<var>$Web_Hdr_Parm</var> retrieves the value of a request header field.
<var>$Web_Hdr_Parm</var> retrieves the value of a request header field.
<var>$Web_Hdr_Parm</var> takes four arguments and returns a string, or null for any error condition.


==Syntax==
==Syntax==
<p class="syntax"><span class="term">%string</span> = <span class="literal">$Web_Hdr_Parm</span>( <span class="term">fieldname</span>, <span class="term">occurrence</span>, start, length )
<p class="syntax"><span class="term">%string</span> = <span class="literal">$Web_Hdr_Parm</span>( <span class="term">fieldname</span>, <span class="term">occurrence</span>, [<span class="term">start</span>], [<span class="term">length</span>] )
</p>
</p>


===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>%string</th>
<td>A string variable to contain the returned field value, or to contain a null for any error condition.
 
<tr><th>fieldname</th>
<tr><th>fieldname</th>
<td>The name of the header field, returned by <var>$Web_Hdr_Name</var>. Required argument if ''occurrence'' not specified, otherwise optional.</td></tr>
<td>The name of the header field, returned by <var>$Web_Hdr_Name</var>. Required argument if <var class="term">occurrence</var> not specified; otherwise optional.</td></tr>
 
<tr><th>occurrence</th>
<tr><th>occurrence</th>
<td>The occurrence number of a header field, or the occurrence number of the header field matching ''fieldname'', if ''fieldname'' is specified. Optional argument if ''fieldname'' is specified, otherwise it is required.</td></tr>
<td>The occurrence number of a header field, or the occurrence number of the header field matching <var class="term">fieldname</var>, if <var class="term">fieldname</var> is specified. This is an optional argument if <var class="term">fieldname</var> is specified; otherwise it is required.</td></tr>
 
<tr><th>start</th>
<tr><th>start</th>
<td>Starting position within the field. Optional argument which defaults to 1.</td></tr>
<td>Starting position within the field. This is an optional argument which defaults to 1.</td></tr>
 
<tr><th>length</th>
<tr><th>length</th>
<td>Length to return. This is an optional argument which defaults to the length of the header field. The length of a header field can be determined with <var>$Web_Hdr_Len</var>.
<td>Length to return. This is an optional argument which defaults to the length of the header field. The length of a header field can be determined with <var>$Web_Hdr_Len</var>.
</td></tr></table>
</td></tr></table>


==Notes==
==Usage notes==
<ul>
<li>Even though "METHOD", "URL", "HTTP", and "ISINDEX" are not named HTTP header parameters, they are valid keywords for the <var>$Web_Hdr_Parm</var> <var class="term">fieldname</var> parameter, returning these values:


<ul>
<table class="thJustBold">
<li>Even though "METHOD", "URL", and "HTTP" are not a named HTTP header parameters, if requested with $web_hdr_parm, the following will be returned for these names:
<tr><th>METHOD</th>
<table class="syntaxTable">
<td>The HTTP method associated with the request.</td></tr>
<tr><th>METHOD</th><td>The HTTP method associated with the request.</td></tr>
 
<tr><th>URL</th><td>The URL associated with the request. It will not contain the protocol (http or https) or host name for the request as these are not sent by the browser. The protocol (http vs. https) can be determined by the [[$Web_Secure]] function and the host name sent by the browser can usually be retrieved via the "HOST" header parameter.</td></tr>
<tr><th>URL</th>
<tr><th>HTTP</th><td>The version of HTTP requested by the browser. This is currently almost always going to be "1.1".</td></tr>
<td>The URL associated with the request. The value returned does not contain the protocol (http or https) or host name for the request, as these are not sent by the browser. The protocol (http or https) can be determined by the <var>[[$Web_Secure]]</var> function, and the host name sent by the browser can usually be retrieved with the <var>HOST</var> header parameter.
<p>
The <var>URL</var> value will also not include the query parameters (the part after a question mark) though these can be retrieved via the <var>ISINDEX</var> header parameter. Alternatively, if you want to retrieve a relative URL including its query parameters, you can use <var>[[$Web_Form_Action]]</var>.</p></td></tr>
 
<tr><th>ISINDEX</th>
<td>The query parameters in the URL. This is the part of the URL that comes after a question mark and typically has a <i>name</i>=<i>value</i>&<i>name</i>=<i>value</i>... format. For URL parameters in this format, the [[Janus Web Server $functions#Isindex data/URL parameter processing functions|$Web_Isindex and $Web_URL_Parm]] functions provide an easy way of getting the components of the URL parameters.</td></tr>
 
<tr><th>HTTP</th>
<td>The version of HTTP requested by the browser. This is currently almost always going to be "1.1".</td></tr>
</table>
</table>
</ul>
</ul>
==Examples==
==Examples==
The following example places the value of each header parameter into a <var class="product">User Language</var> %variable of the same name.
The following example places the value of each header parameter into a <var class="product">SOUL</var> %variable of the same name.
<p class="code">&#42; Stash the header values in matching fields.
<p class="code">&#42; Stash the header values in matching fields.
%method = $Web_Hdr_Parm( 'METHOD' )
%METHOD = $Web_Hdr_Parm( 'METHOD' )
%url = $Web_Hdr_Parm( 'URL' )
%URL = $Web_Hdr_Parm( 'URL' )
%version = $Web_Hdr_Parm( 'VERSION' )
%VERSION = $Web_Hdr_Parm( 'VERSION' )
</p>
</p>



Latest revision as of 17:32, 3 February 2016

Value of request header field


$Web_Hdr_Parm retrieves the value of a request header field.

Syntax

%string = $Web_Hdr_Parm( fieldname, occurrence, [start], [length] )

Syntax terms

%string A string variable to contain the returned field value, or to contain a null for any error condition.
fieldname The name of the header field, returned by $Web_Hdr_Name. Required argument if occurrence not specified; otherwise optional.
occurrence The occurrence number of a header field, or the occurrence number of the header field matching fieldname, if fieldname is specified. This is an optional argument if fieldname is specified; otherwise it is required.
start Starting position within the field. This is an optional argument which defaults to 1.
length Length to return. This is an optional argument which defaults to the length of the header field. The length of a header field can be determined with $Web_Hdr_Len.

Usage notes

  • Even though "METHOD", "URL", "HTTP", and "ISINDEX" are not named HTTP header parameters, they are valid keywords for the $Web_Hdr_Parm fieldname parameter, returning these values:
    METHOD The HTTP method associated with the request.
    URL The URL associated with the request. The value returned does not contain the protocol (http or https) or host name for the request, as these are not sent by the browser. The protocol (http or https) can be determined by the $Web_Secure function, and the host name sent by the browser can usually be retrieved with the HOST header parameter.

    The URL value will also not include the query parameters (the part after a question mark) though these can be retrieved via the ISINDEX header parameter. Alternatively, if you want to retrieve a relative URL including its query parameters, you can use $Web_Form_Action.

    ISINDEX The query parameters in the URL. This is the part of the URL that comes after a question mark and typically has a name=value&name=value... format. For URL parameters in this format, the $Web_Isindex and $Web_URL_Parm functions provide an easy way of getting the components of the URL parameters.
    HTTP The version of HTTP requested by the browser. This is currently almost always going to be "1.1".

Examples

The following example places the value of each header parameter into a SOUL %variable of the same name.

* Stash the header values in matching fields. %method = $Web_Hdr_Parm( 'METHOD' ) %url = $Web_Hdr_Parm( 'URL' ) %version = $Web_Hdr_Parm( 'VERSION' )

See also