⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 features.pi3

📁 mini http server,可以集成嵌入到程序中,实现简单的web功能
💻 PI3
📖 第 1 页 / 共 3 页
字号:
	CheckAccess AccessByFile RequirePermissions="R"

	CheckType ConditionalGet
	CheckType CheckForDirectory SetType="internal/x-directory"

	#
	# Otherwise: Set the media type based on the file extension
	#
	CheckType MIMETypeByExtension 

	#
	# Set StatusCode 501 for not allowed HTTP verbs
	#
	CheckType Condition="&not(&regexp(*$m*,GETHEADPOST))" StatusCode StatusCode="501"

	#
	# Return 'COMPLETED' so an internal error will not be raised
	#
	CheckType ReturnCode ReturnCode="COMPLETED"

	#
	# Most requests refer to a file, so put that first 
	#
	# Handle GET and HEAD requests by sending a file if
	#	- The Value of ObjectMap in the response DB is ""
	#	AND
	#	- The Media type of the resource does not match internal/* 
	#
	Handle Condition="&not(&or(&dblookup(response,string,ObjectMap),\
&regexp('internal/*',$c)))" SendFile 
	Handle Condition="&cmp($c,internal/x-directory)" DirectoryIndexes
	Handle Condition="&cmp($c,internal/x-server-parsed-html)" SendSSI \
		Exec=Yes ExecFileFixup="\n/* exec file="" maps to Standard CGI (Scripts) */\
&dbreplace(response,string,ObjectMap,Scripts)\n&dbreplace(response,rfc822,Content-Type,internal/x-cgi)"
	Handle Condition="&cmp($c,internal/x-imagemap)" ImageMap
	Handle Condition="&cmp($c,internal/x-server-parsed-php)" PHP4
	Handle SendFile Methods="GET | HEAD | POST" \
DescriptionFile=".desc" \
Annotation="From:\t$A$MHost:\t$h$MTime:\t$t$MUrl:\t"$r\"$M" \
UploadPath="" \
Limit="4194304"
	Log AccessLogger File="Logs/access.txt"
	Log ReturnCode ReturnCode=COMPLETED
	Destroy DeleteTemporaryFiles
</Object>

# ---
#
# Options
#
#	Handle requests with HTTP/1.1 methods OPTIONS | TRACE
#
# ---
<Object>
	Name Options
	Class FlexibleHandlerClass
	Condition "&or(&cmpi($m,OPTIONS),&cmpi($m,TRACE))"
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess ReturnCode ReturnCode=COMPLETED
	CheckType ReturnCode ReturnCode=COMPLETED

	# Extended SendFile object will handle HTTP/1.1 requests
	Handle SendFile Methods="OPTIONS | TRACE"
</Object>

# ---
#
# Upload
#
#	Handle file requests with HTTP/1.1 methods other than GET | HEAD
#
# ---
<Object>
	Name Upload
	Class FlexibleHandlerClass
	Condition "&not(&or(&cmpi($m,GET),&cmpi($m,HEAD)))"
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess ReturnCode ReturnCode=COMPLETED
	CheckType ReturnCode ReturnCode=COMPLETED

	# Extended SendFile object will handle HTTP/1.1 requests
	Handle SendFile Methods="GET | HEAD | POST | PUT | DELETE" \
Annotation="From:\t$A$MHost:\t$h$MTime:\t$t$MUrl:\t"$r\"$M" \
DescriptionFile=".desc"
</Object>

# ---
#
# Documentation
#
#	Handler sequence for documentation.
#
# ---
<Object>
	Name Documentation
	Class FlexibleHandlerClass

	#
	# Only execute this sequence for the documentation (check for
	# the appropriate marker).
	#
	# Don't handle special resource types (internal/...)
	#
	Condition "&and(&cmp(&dblookup(response,string,ObjectMap),Pi3Docs),\
&not(&regexp('internal/*',$c)))"

	#
	# Check if file is a directory
	# 
	CheckType CheckForDirectory SetType="internal/x-directory"

	#
	# Lookup media type by extension
	#
	CheckType MIMETypeByExtension

	#
	# Force all non-internal media types to 'text/html'
	#
	CheckType Condition="&not(&regexp('internal/*',$c))" Action \
		Pi3Expression="&dbreplace(response,rfc822,Content-Type,text/html)"

	#
	# Return 'COMPLETED' so as not to fall into other cases
	#
	CheckType ReturnCode ReturnCode="COMPLETED"

	#
	# For documentation, Send documentation with header and footer
	#
	Handle SendFile HeaderPattern="<BODY BACKGROUND="/icons/\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)"/*background depends on vhost*/\
 BGCOLOR="#FFFFFF">\n"
</Object>

# ---
#
# FastCGIIOObject
# 
# IOObject for communicating with fast CGI application servers. This
# one uses the TCP/IP transport.
#
# ---
<Object>
	Name FastCGIIOObject
	Class TCPIPIOClass
	Type Active

	# Timeouts. -1 specifies no timeout.
	RecvTimeout 20
	SendTimeout 20
</Object>


# ---
# 
# Scripts, WinScripts, ISAPI, FastCGIScripts, Pi3Expr
#
#	Handler sequences for resources which have mapped to these
# 	respective types
#
# ---
<Object>
	Name Scripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),Scripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle StandardCGI
</Object>
<Object>
	Name WinScripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),WinScripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle WindowsCGI
</Object>
<Object>
	Name ISAPI
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),ISAPI)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle ISAPIExtensions
</Object>

<Object>
	Name ISAPIExtensions
	Class ISAPI20Class
	# These are the server variables that are sent to the
	# extension
	Variable "ALL_HTTP=%a"
	Variable "CONTENT_LENGTH=%l"
	Variable "AUTH_TYPE=$x"
	Variable "CONTENT_TYPE=$C"
	Variable "HTTPS=$g"
	Variable "GATEWAY_INTERFACE=CGI/1.1"
	Variable "PATH_INFO=$I"
	Variable "PATH_TRANSLATED=$Z"
	Variable "QUERY_STRING=$q"
	Variable "REMOTE_ADDR=$A"
	Variable "REMOTE_HOST=$h"
	Variable "REMOTE_IDENT=$i"
	Variable "REMOTE_USER=$u"
	Variable "REQUEST_METHOD=$m"
	Variable "SCRIPT_NAME=$z"
	Variable "SERVER_NAME=$v"
	Variable "SERVER_PORT=$p"
	Variable "SERVER_PROTOCOL=$H"
	Variable "SERVER_SOFTWARE=$S"
	ExtraHeaders Yes
	ExtraHeadersPrefix "HTTP_"
	ExtraHeadersIgnore "Content-Type Content-Length"
</Object>

<Object>
	Name FastCGIScripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),FastCGIScripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess ReturnCode ReturnCode="COMPLETED"
	CheckType ReturnCode ReturnCode="COMPLETED"
	Handle FastCGI \
		IOObject="FastCGIIOObject" \
		Variable="AUTH_TYPE=$x" \
		Variable="CONTENT_LENGTH=$Y" \
		Variable="CONTENT_TYPE=$C" \
		Variable="HTTPS=$g" \
		Variable="&if($K,HTTPS_KEYSIZE=$K,)" \
		Variable="&if($K,HTTPS_SECRETKEYSIZE=$G,)" \
		Variable="PATH_INFO=$I" \
		Variable="PATH_TRANSLATED=$Z" \
		Variable="QUERY_STRING=$q" \
		Variable="REMOTE_ADDR=$A" \
		Variable="REMOTE_HOST=$h" \
		Variable="REMOTE_IDENT=$i" \
		Variable="REMOTE_USER=$u" \
		Variable="REQUEST_METHOD=$m" \
		Variable="SCRIPT_NAME=$z" \
		Variable="SERVER_NAME=$v" \
		Variable="SERVER_PORT=$p" \
		Variable="SERVER_PROTOCOL=$H" \
		Variable="SERVER_SOFTWARE=$S"
</Object>

<Object>
	Name Pi3Expr
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),Pi3Expr)"
	CheckPath ReturnCode ReturnCode="COMPLETED"
	CheckAccess ReturnCode ReturnCode="COMPLETED"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle SendPi3Expression HTTPEquiv="Content-Type: text/html" \
		Pi3Expression="\
/*											 */\
/*											 */\
/* A Large Pi3Expression to send to the client */\
/*			  in one go					  */\
/*											 */\
/*   This will generate a dynamic HTML page	*/\
/*											 */\
<TITLE>Pi3Expressions - DB Dump</TITLE>\
<HTML><BODY BACKGROUND="/icons/Pi3Tile.gif">\
<CENTER><H2>Pi3Expressions - DB Dump</H2>\
<A NAME="index">$M\
<UL>$M\
<LI><A HREF="#connection">Connection DB</A>$M\
<LI><A HREF="#request">Request DB</A>$M\
<LI><A HREF="#response">Response DB</A>$M\
<LI><A HREF="#host">Host DB</A>$M\
</UL>$M\
<HR>$M\
<A NAME="connection">$M\
<H3>Dump of Connection DB <I>dblookup(connection,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(connection,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(connection,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(connection,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="request">$M\
<H3>Dump of Request DB <I>dblookup(request,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(request,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(request,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(request,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="response">$M\
<H3>Dump of Response DB <I>dblookup(response,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(response,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(response,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(response,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="host">$M\
<H3>Dump of Host DB <I>dblookup(host,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(host,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(host,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(host,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
</CENTER><HR></BODY></HTML>"

</Object>

# ---
#
#	Virtual hosting handlers and configuration
#
# ---

#
# Host2 Virtual host object
<Object>
	Name Host2
	Class VirtualHostClass
	Administrator mr_web@Host2.dom
	HostName www.johnroy.com/host2
	ServerPort 80
</Object>

#
# Virtual host mappings
#
<Object>
	Name VirtualHosts
	Class FlexibleHandlerClass

	#
	# if the URL starts with '/host2/' assign to virtual host 2
	#
	HostMap VirtualHostByURL VirtualHostObject="Host2" URLPath="/host2/"

	#
	# Introduce a mapping
	Mapping Host2Mappings
</Object>

#
# Override some mappings for Host2 only
#
<Object>
	Name Host2Mappings
	Class FlexibleHandlerClass

	#
	# These mappings only apply to Host2
	#
	Condition "&cmp($o,Host2)"

	#
	# map to second document root
	#
	Mapping PathMapper From="/" To="WebRoot2/"
</Object>

#
# Host1 mappings
#
<Object>
	Name Host1Mappings
	Class FlexibleHandlerClass
	#
	# These mappings only apply to MainVirtualHostInformation
	#
	Condition "&cmp($o,MainVirtualHostInformation)"
	#
	# map to first document root
	#
	Mapping PathMapper From="/" To="WebRoot/"
</Object>


# ---
#
# HTTPLogicObject
#
# 	HTTP Logic object, dispatches requests to all other handlers
#
# ---
<Object>
	Name HTTPLogicObject
	Class HTTPDispatcherClass
	Handlers Start Options Scripts WinScripts FastCGIScripts Documentation Pi3Expr ISAPI Upload Default
	KeepOpen On
	ServerRoot ./../
	ServerStamp Pi3Web/2.0.3
	DefaultHost MainVirtualHostInformation
	MIMEFile "Fragment/Mime.typ"
	DefaultMIMEType "application/octet-stream"
	ErrorLogFile "Logs/error.txt"

	# Specifying a file for DebugLogFile effectively turns on debugging
#	DebugLogFile "Logs/debug.txt"

	#
	# The following to directives specify expressions to be logged
	# before and after each handler execution respectively.
	# The expression as given logs process/thread and handler context
	# information indented to the nested handler level.
	#
	# Timing information is also given for performance tuning.
	#
	# This logging information is EXTREMELY verbose. Don't even
	# think about using it in a production server
	#
	DebugBeforeHandler "[$P:$k] &align(,$X)&align(,$X) |--> $T \
-------- &align($N,12) &align($R,12) $n \"$r\" $s"
	DebugAfterHandler "[$P:$k] &align(,$X)&align(,$X) |<-- $T \
&align($D,8) &align($N,12) &align($R,12) $n \"$r\" $s"
</Object>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -