3 # Copyright 2016 Paul Hänsch
5 # This file is part of shcgi.
7 # shcgi is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # shcgi is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with shcgi. If not, see <http://www.gnu.org/licenses/>.
20 if [ "$1" = '--server' ]; then
22 ncat -klc "$call --ncat" $@
26 export REMOTE_ADDR="${NCAT_REMOTE_ADDR}"
27 export SERVER_NAME="${NCAT_LOCAL_ADDR}"
28 export SERVER_PORT="${NCAT_LOCAL_PORT}"
33 /^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$/{
35 s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;export REQUEST_METHOD='\''\1'\'';p
37 s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;\2;
38 s;'\'';'\''\\'\'''\'';g
39 s;^.*$;export PATH_INFO='\''&'\'';p
41 s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;\3;
42 s;'\'';'\''\\'\'''\'';g
43 s;^.*$;export QUERY_STRING='\''&'\'';p
45 s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;export SERVER_PROTOCOL='\''\4'\'';p
49 /^[Pp][Rr][Oo][Xx][Yy]: /d
54 s;'\'';'\''\\'\'''\'';g
58 y;abcdefghijklmnopqrstuvwxyz-;ABCDEFGHIJKLMNOPQRSTUVWXYZ_;
59 s;^.+$;export HTTP_&=;
75 aConnection: close\r\n\r
76 /^HTTP\/[0-9]\.[0-9] [1-5][0-9][0-9] .*/bX
77 s;^(.+\n)?Location: .*$;HTTP/1.1 302 Found\r\n&;
78 s;^(.+\n)?Content-Type: .*$;HTTP/1.1 200 OK\r\n&;