Server settings file format

This page describes ahttpserver setting file format (server.config) - in current releases this file is always loaded from server executable location directory.

<?xml version="1.0" encoding="utf-8"?>
<settings>

	<!-- log-level: "Debug", "Info", "Warning", "Error", "Critical" - if none of them - then debug -->
	<log log-level="info" max-file-size="4194304">

		<!-- {app-path} - path to directory where application is located (with trailing slash),
				 {timestamp} - generated timestamp -->
		<path>{app-path}log\server_{timestamp}.log</path>
	</log>
		
	<!-- timeouts defined in seconds -->
	<!-- 
		Default values in code:
		workers-count="500"
		pooling-enabled="true"

		keep-alive-enabled = "true"
		keep-alive-timeout = "5"
		gzip-deflate-enabled = "true"
        
		server-socket-timeout = "00"
		command-socket-timeout = "30" 
		response-buffer-size = "2048576" bytes
		
		{app-path} can be used in 'uploads-dir'
		-->

	<server
		version = "ahttpserver"
		port="5555"
		ip-address="0.0.0.0"
		workers-count="100"
		pooling-enabled="true"
		command-port="5556"
		root="root"

		keep-alive-enabled = "true"
		keep-alive-timeout = "10"
		gzip-deflate-enabled = "true"
		server-socket-timeout = "900"
		command-socket-timeout = "30"
				
		response-buffer-size = "8194304"
		max-chunk-size = "512144"

		directory-config-file = "directory.config"
		messages-file = "messages.config"
		
		uploads-dir = "c:\\temp\\ahttp"
		locale=".1251"
		>

		<mime-types file="{app-path}mime-types.config" />

		<!-- All handlers must be registered there, concrete 
			assignments will be defined in <directory> elements -->
		<handlers>
			<register name="handler_python" default-ext=".py; .pyhtml">
				<path>{app-path}handler_python.dll</path>
				<!-- parameter name="uploads-dir">c:\temp\handler_python\</parameter -->
			</register>
			<register name="handler_php" default-ext=".php">
				<path>{app-path}handler_isapi.dll</path>
				<parameter name="engine">c:\PHP\php5isapi.dll</parameter>
				<parameter name="free-library">true</parameter>
				<parameter name="check-file-exists">true</parameter>
			</register>
			<register name="handler_aspnet" default-ext=".aspx; .ashx; .asmx; .axd">
				<path>{app-path}handler_aspnet.dll</path>
				<parameter name="init-root">false</parameter>
				<parameter name="load-applications">root</parameter>
				<parameter name="recycling-timeout">30</parameter> <!-- timeout in seconds -->
			</register>
		</handlers>

	</server>

	<!-- virtual-path for root: "/"
				'charset' - will be used when FS content is shown   
				default 'max-request-size': 2097152 bytes -->
	<directory name="root"
			browsing-enabled="true"
			charset="Windows-1251"
			max-request-size="2097152"
			enable-parent-path-access="true">

		<directory-params>
			<parameter name="asp-recycle-by-requests-count">100</parameter>
			<parameter name="asp-recycle-by-uptime">30</parameter> <!-- in minutes -->
            <parameter name="asp-reload-url">/</parameter>
		</directory-params>
		
		<path>d:\work\web\</path>

		<default-documents>
			<add>index.html</add>
			<add>index.htm</add>
			<add>main.html</add>
            <add>Default.aspx</add>
		</default-documents>

		<!-- ext="*" - will be applied to all requests -->
		<!-- ext="." - will be applied to directory/file without extension -->
		<handlers>
			<add name="handler_python"/>
			<add name="handler_php" />
			<add name="handler_aspnet"/>
       </handlers>

		<!-- Record attributes: 
				{name} - name of item, 
				{size} - size of item in kb,
				{url} - url to open item
				{time} - last modify dat/time of item,
				{page-url} - url to current page
				{parent-url} - url to parent directory
				{files-count} - files count in current directory
				{directories-count} - sub-directories count in current directory
				{errors-count} - reading errors count 
				{tab} - will be replaced with '\t'
		-->
		<header-template>
			&lt;html&gt;
			&lt;head&gt;
			&lt;title&gt;Directory content: {page-url}&lt;/title&gt;
			&lt;style&gt;
			BODY { padding: 10px; margin: 10px; font: 10pt Tahoma, Arial; color: #999; background-color: #f5f5f5;}
            A:link      { color: #000; }
            A:visited   { color: #666; }
            A:hover     { color: #cc0000; }

			H1 {font-size: 12pt; font-weight: bold; color: #cc0000; }
			HR {height:1px; border: 1px solid #333; color: #333;}
			TABLE {font-size: 100%;}
			TD { padding: 0 10px 0 10px; text-align: left; }

			&lt;/style&gt;
			&lt;/head&gt;
			&lt;body&gt;
			&lt;h1&gt;Directory: &lt;i&gt;{page-url}&lt;/i&gt;&lt;/h1&gt;
			&lt;hr /&gt;
			&lt;table border="0" cellpadding="0" cellspacing="0"&gt;
		</header-template>

		<parent-directory-template >
			&lt;tr&gt;&lt;td colspan="4" style="padding-bottom: 10px;"&gt;
			&lt;a href="{parent-url}"&gt;[parent directory]&lt;/a&gt;
			&lt;/td&gt;&lt;/tr&gt;
		</parent-directory-template>

		<directory-template>
			&lt;tr&gt;
			&lt;td&gt;{time}&lt;/td&gt;
			&lt;td&gt; &amp;lt;dir&amp;gt; &lt;/td&gt;
			&lt;td&gt; &lt;img border="0" align="middle" src="/server_data/images/icon_dir.gif"/&gt; &lt;/td&gt;
			&lt;td&gt; &lt;a href="{url}"&gt;  {name}&lt;/a&gt; &lt;/td&gt;
			&lt;/tr&gt;
		</directory-template>

		<virtual-directory-template >
			&lt;tr&gt;
			&lt;td&gt;{time}&lt;/td&gt;
			&lt;td&gt; &amp;lt;virtual&amp;gt; &lt;/td&gt;
			&lt;td&gt; &lt;img border="0" align="middle" src="/server_data/images/icon_virtual_dir.gif"/&gt; &lt;/td&gt;
			&lt;td&gt;&lt;a href="{url}"&gt;{name}&lt;/a&gt;&lt;/td&gt;
			&lt;/tr&gt;
		</virtual-directory-template>

		<file-template >
			&lt;tr&gt;
			&lt;td&gt;{time}&lt;/td&gt;
			&lt;td&gt;{size}&lt;/td&gt;
			&lt;td&gt; &lt;img border="0" align="middle" src="/server_data/images/icon_file.gif"/&gt; &lt;/td&gt;
			&lt;td&gt;&lt;a href="{url}"&gt;{name}&lt;/a&gt;&lt;/td&gt;
			&lt;/tr&gt;
		</file-template>

		<footer-template>
			&lt;/table&gt;
			&lt;hr /&gt;
			Files: {files-count}&lt;br&gt;
			Directories: {directories-count}&lt;br&gt;
			Reading errors: {errors-count}
			&lt;hr /&gt;
			&lt;/body&gt;
			&lt;/html&gt;
		</footer-template>

	</directory>

	<directory name="server_data"
			parent="root">
		<virtual-path>server_data</virtual-path>
		<path>{app-path}web</path>
	</directory>
    
	<directory name="disk_c"
		parent="root">
		<handlers>
			<clear />
		</handlers>
		<virtual-path>disk_c</virtual-path>
		<path>c:\</path>
	</directory>

	<directory name="mvc" parent="root">
		<handlers>
			<add name="handler_aspnet" ext="*"/>
			<remove name="handler_aspnet" ext=".gif; .js; .css; .jpg; .png"/>
		</handlers>
		<virtual-path>mvc</virtual-path>
		<relative-path>mvc</relative-path>

		<directory-params>
			<parameter name="asp-reload-url">Home</parameter>
			<parameter name="asp-recycle-by-requests-count">100</parameter>
			<parameter name="asp-recycle-by-uptime">30</parameter> <!-- in minutes -->
		</directory-params>
    </directory>
</settings>

First section of settings file - log defines global file logger setup, well known logging levels set is used.

Second section of settings file - server defines HTTP server startup/runtime behavior: server's port (port attribute), IP address to bind on it (now only IPv4 is supported).

Server parameters

  • workers-count: Maximal worker threads count in thread's pool.
  • pooling-enabled: Defines server working mode - single threaded (pooling-enabled = 'false') or multithreaded.
  • command-port: Used in ahttpserver to open additional listening port to receive server control commands ('start', 'stop', 'reload').
  • keep-alive-enabled: Setup HTTP Keep-Alive mode.
  • server-socket-timeout: HTTP server socket read/write timeout (in seconds).
  • response-buffer-size: HTTP response buffer size (in bytes).
  • max-chunk-size: Maximal chunk size in chunked response mode (defined in bytes).
  • directory-config-file: Name of inplace file, located in server virtual directory and used to load default document list, plugins registration and server URL mappings setup (see sample in sources package).
  • messages-file: Server messages localization file.
  • uploads-dir: Global uploads directory to store posted files content.
  • locale: Important setting - call setlocale (LCCTYPE, localeStr.cstr()) will be performed at server startup when this attribute is not empty. Locale setup can be used to force mbstowcs work correctly, for example I have setup ".1251" locale to correctly transform file names defined in Windows-1251 encoding to Unicode.
  • mime-types: This element defines correspondence between file extension and MIME type send in 'Content-Type' header for this file. Types can be defined directly in this element's body or loaded from external file.
  • handlers: This element should contain all planned to use handlers registration. Each handler registration defines path to DLL/SO file to load and set of parameters that will be sent to handler initialization method. Handler in ahttp library - it is plugin that can perform processing of defined file types, like ISAPI extension in IIS or HttpHandler in ASP.NET.
  • modules: This element should contain all planned to use modules registration. Each module registration defines path to DLL/SO file to load and set of parameters that will be sent to module initialization method. Module in ahttp library - it is plugin that can contain set of callbacks which will be used at defined HTTP request processing end-points like HttpModule in ASP.NET. At present following events for module are supported: ModuleCallbackOnRequestBegin, ModuleCallbackOnRequestResolve, ModuleCallbackOnRequestMapHandler, ModuleCallbackOnResponsePreSendHeaders, ModuleCallbackOnResponsePreSendContent, ModuleCallbackOnResponseEnd.

Virtual directory settings

Virtual directory setup by directory element. Each virtual directory can be defined by absolute file-system path ('path' attribute) or by relative path from parent's directory ('relative-path' attribute).
  • name: Mandatory attribute - used to build directories tree from server's root.
  • path: Used to setup virtual directory absolute FS path.
  • relative-path: Used to setup virtual directory relative FS path.
  • virtual-path: Defines virtual path of directory.
  • max-request-size: Optional attribute - defines maximal HTTP request size that can be processed by server. Default value - 2097152 bytes.
  • enable-parent-path-access: Optional attribute - used to deny access to parent directory from mapPath method. Default value - 'false'.
  • browsing-enabled: Enables directory browsing mode. "header-template", "parent-directory-template", "directory-template", "virtual-directory-template", "file-template" and "footer-template" used to format directory content HTML.
  • handlers: This element defines ahttp handlers setup for current directory, can contain following elements: 'add', 'remove', 'clear', 'register'. All handlers registered for parent directory are applied to all children by default.

Last edited Dec 7, 2009 at 2:16 PM by artiz, version 3

Comments

No comments yet.