--- parser3/etc/auto.p.in 2020/12/07 16:04:22 1.1
+++ parser3/etc/auto.p.in 2020/12/31 10:10:28 1.4
@@ -1,4 +1,20 @@
-#$Id: auto.p.in,v 1.1 2020/12/07 16:04:22 moko Exp $
+#$Id: auto.p.in,v 1.4 2020/12/31 10:10:28 moko Exp $
+
+@auto[]
+#source/client charsets
+$request:charset[utf-8]
+$response:charset[utf-8]
+
+$response:content-type[
+ $.value[text/html]
+ $.charset[$response:charset]
+]
+
+#$SQL.connect-string[mysql://user:pass@host/db?charset=utf8]
+#$SQL.connect-string[sqlite://db]
+#$SQL.connect-string[pgsql://user:pass@host/db]
+#$SQL.connect-string[odbc://DSN=datasource^;UID=user^;PWD=password]
+
@conf[filespec]
$confdir[^file:dirname[$filespec]]
@@ -83,11 +99,12 @@ $LIMITS[
$.post_max_size(10*0x400*0x400)
]
+#$HTTPD[
+# $.mode[threaded]
+#]
+
#$MAIL[
-# $.sendmail[your sendmail command goes here]
-# these are tried when no 'sendmail' specified:
-# /usr/sbin/sendmail -t -i -f postmaster
-# /usr/lib/sendmail -t -i -f postmaster
+# $.SMTP[localhost]
#]
@@ -155,17 +172,87 @@ $result(def $env:REMOTE_ADDR && ^env:REM
}
-@auto[]
-#source/client charsets
-$request:charset[utf-8]
-$response:charset[utf-8]
+@httpd-include[filename]
+^use[$filename; $.main(true) ]
+^main[]
+
+@httpd-index[dir][list]
+^fatal_error[Index of $dir;Index of $dir;
+ $list[^file:list[$dir]]
+ ^list.sort{^if($list.dir)[0;1] $list.name}
+ ^list.menu{
+ ^if($list.dir){/}$list.name
+ }
+]
+$response:status(200)
-$response:content-type[
- $.value[text/html]
- $.charset[$response:charset]
+@httpd-option[option]
+$result[^if($option is junction){^option[]}(^option.match[$httpd.parser]){^httpd-include[$option]}{$option}]
+
+@httpd-file[filename]
+$result[^if(^filename.match[$httpd.parser]){^httpd-include[$filename]}{$response:body[ $.file[$filename] $.name[] ]}]
+
+@httpd-log[filename;detail][now;line]
+$now[^date::now[]]
+$line[$env:REMOTE_ADDR [^now.sql-string[]] "$request:method $request:uri"$detail^#0A]
+^line.save[append;$filename]
+
+@httpd-404[]
+$response:status[404]
+The requested URL was not found on this server.
+
+
+@httpd-main[][uri;basic]
+
+$httpd[
+ $.parser[\.(html|phtml)^$]
+ $.index[index.html]
+# $.autoindex(true)
+ $.404[$httpd-404]
+# $.404[/_doc.html]
+# $.fix-trailing-slash(true)
+# $.auth[ $.url[^^/\.?admin/] $.login[admin] $.password[change me] $.realm[site administration] ]
+ $.deny[(/\.ht[^^/]+|\.p|\.cfg)^$]
+ $.403[Permission denied]
+ $.memory(64000)
+# $.log[/access.log]
]
-#$SQL.connect-string[mysql://user:pass@host/db?charset=utf8]
-#$SQL.connect-string[sqlite://db]
-#$SQL.connect-string[pgsql://user:pass@host/db]
-#$SQL.connect-string[odbc://DSN=datasource^;UID=user^;PWD=password]
+$response:server[Parser$env:PARSER_VERSION]
+$response:date[^date::now[]]
+$response:connection[close]
+$uri[^request:uri.match[\?.*][]{}]
+$uri[^string:unescape[uri;$uri; $.charset[UTF-8] ]]
+
+^if(def $httpd.log){
+ ^httpd-log[$httpd.log]
+}
+^if(def $httpd.memory && $status:memory.ever_allocated_since_compact > $httpd.memory){
+ ^memory:compact[]
+}
+
+^if(def $httpd.auth.url && ^uri.match[$httpd.auth.url]){
+ $basic[$httpd.auth.login:$httpd.auth.password]
+ ^if($env:HTTP_AUTHORIZATION ne "Basic ^basic.base64[]"){
+ $response:WWW-Authenticate[Basic realm="$httpd.auth.realm"]
+ ^return[$response:status[401]]
+ }
+ $env:REMOTE_USER[$httpd.auth.login]
+}
+
+^if(def $httpd.deny && ^uri.match[$httpd.deny]){
+ $response:status[403]
+ $result[^httpd-option[$httpd.403]]
+}(def $httpd.fix-trailing-slash && ^uri.match[^^[^^.]+[^^/.]^$]){
+ $result[$response:location[$uri/^if(def $request:query){?^taint[as-is;$request:query]}}]]
+}(def $httpd.index && -f "$uri/$httpd.index"){
+ $result[^httpd-file[$uri/$httpd.index]]
+}($httpd.autoindex && -d "$uri"){
+ $result[^httpd-index[$uri]]
+}(-f $uri){
+ $result[^httpd-file[$uri]]
+}{
+# $form:request[^uri.mid(1)]
+ $result[^httpd-option[$httpd.404]]
+}
+