[client_host]

Description

Link: [client_host]
Author: Johan Sölve
Category: Client
Version: 6.x
License: Public Domain
Posted: Feb. 15, 2006
Updated: Sep. 06, 2006
More by this author...
This tag returns the host name from the visitor's request header. Useful for example to implement virtual hosts functionality in Lasso.

Parameters

none


Sample Usage

[client_host]
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?lassoscript

define_tag: 'client_host', -priority='replace';
	local: 'output'=null;
	// get the request header and normalize line endings to account for IIS quirk
	local: 'requestheader' = client_headers;
	#requestheader -> (replace: '\r\n', '\r');
	#requestheader -> (replace: '\n', '\r');
	#requestheader	= #requestheader -> (split: '\r');
	iterate: #requestheader, (local: 'headerfield');
		if: #headerfield -> (beginswith: 'Host:');
			#output=#headerfield;
			#output -> (removeleading: 'Host:');
			#output -> trim;
			loop_abort;
		else: #headerfield -> (beginswith: 'HTTP_Host:');
			// try to find header field modified by IIS (all fields are prefixexd by HTTP_)
			#output=#headerfield;
			#output -> (removeleading: 'HTTP_Host:');
			#output -> trim;
			loop_abort;
		/if;
	/iterate;
	return: #output;
/define_tag;

?>

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular