-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-import cgi
-import sys
-from os import environ
-
-fields = cgi.FieldStorage()
-msg = ""
-
-if fields.getvalue('message'):
- msg = str(fields.getvalue('message'))
-
-print "Access-Control-Allow-Origin: %s" % environ.get("HTTP_ORIGIN", "")
-print "Cache-Control: no-cache"
-print "Content-Type: text/plain"
-print
-sys.stdout.write(msg)
+MSG=""
+if [ "$REQUEST_METHOD" = "GET" ]; then
+ val=`echo -n "$QUERY_STRING" | cgi-getfield message`
+elif [ "$REQUEST_METHOD" = "POST" ]; then
+ val=`cgi-getfield message $CONTENT_LENGTH`
+fi
+[ $? -eq 0 ] && MSG="$val"
+echo "Access-Control-Allow-Origin: $HTTP_ORIGIN"
+echo "Cache-Control: no-cache"
+echo "Content-Type: text/plain"
+echo
+echo -n $MSG
-#!/usr/bin/python
-
-import cgi
-import os
-referer = os.getenv("HTTP_REFERER")
-pyrefer = referer.encode()
-print "Content-type: text/html"
-form = '''
-<!doctype html>
+#!/bin/sh
+#
+referer="$HTTP_REFERER"
+echo "Content-type: text/html"
+echo
+form='<!doctype html>
<html>
<head>
<title>history.pushState/replaceState and referer headers</title>
<noscript><p>Enable JavaScript and reload</p></noscript>
<div id="log"></div>
<script type="text/javascript">
-var pyreferer = "'''
-print form + pyrefer + '";'
-print '''
-var httpReferer = unescape(pyreferer);
-var lastUrl = location.href.replace(/\/[^\/]*$/,'\/009-2.html?1234');
+var pyreferer = "'
+echo "$form$referer\";"
+echo 'var httpReferer = unescape(pyreferer);
+var lastUrl = location.href.replace(/\/[^\/]*$/,"\/009-2.html?1234");
parent.test(function () {
parent.assert_equals( httpReferer, lastUrl );
-}, 'HTTP Referer should use the pushed state');
+}, "HTTP Referer should use the pushed state");
parent.test(function () {
parent.assert_equals( document.referrer, lastUrl );
-}, 'document.referrer should use the pushed state');
+}, "document.referrer should use the pushed state");
window.onload = function () {
setTimeout(function () {
- try { history.pushState('','','009-4.html?2345'); } catch(e) {}
- location.href = '009-5.php';
+ try { history.pushState("","","009-4.html?2345"); } catch(e) {}
+ location.href = "009-5.php";
},10);
};
</script>
</body>
-</html>
-'''
+</html>'
-#!/usr/bin/python
-
-import cgi
-import os
-referer = os.getenv("HTTP_REFERER")
-pyrefer = referer.encode()
-print "Content-type: text/html"
-form = '''
-<!doctype html>
+#!/bin/sh
+#
+referer="$HTTP_REFERER"
+echo "Content-type: text/html"
+echo
+form='<!doctype html>
<html>
<head>
<title>history.pushState/replaceState and referer headers</title>
<noscript><p>Enable JavaScript and reload</p></noscript>
<div id="log"></div>
<script type="text/javascript">
-var pyreferer = "'''
-print form + pyrefer + '";'
-print '''
-var httpReferer = unescape(pyreferer);
-var lastUrl = location.href.replace(/\/[^\/]*$/,'\/009-4.html?2345');
+var pyreferer = "'
+echo "$form$referer\";"
+echo 'var httpReferer = unescape(pyreferer);
+var lastUrl = location.href.replace(/\/[^\/]*$/,"\/009-4.html?2345");
parent.test(function () {
parent.assert_equals( httpReferer, lastUrl );
-}, 'HTTP Referer should use the replaced state');
+}, "HTTP Referer should use the replaced state");
parent.test(function () {
parent.assert_equals( document.referrer, lastUrl );
-}, 'document.referrer should use the replaced state');
+}, "document.referrer should use the replaced state");
parent.done();
</script>
</body>
-</html>
-'''
+</html>'
-#!/usr/bin/python
-
-import cgi
-import os
-referer = os.getenv("HTTP_REFERER")
-pyrefer = referer.encode()
-print "Content-type: text/html"
-form = '''
-<!doctype html>
+#!/bin/sh
+#
+referer="$HTTP_REFERER"
+echo "Content-type: text/html"
+echo
+form='<!doctype html>
<html>
<head>
<title>history.pushState/replaceState and referer headers (before onload)</title>
<noscript><p>Enable JavaScript and reload</p></noscript>
<div id="log"></div>
<script type="text/javascript">
-var pyreferer = "'''
-print form + pyrefer + '";'
-print '''
-var httpReferer = unescape(pyreferer);
-var lastUrl = location.href.replace(/\/[^\/]*$/,'\/010-2.html?1234');
+var pyreferer = "'
+echo "$form$referer\";"
+echo 'var httpReferer = unescape(pyreferer);
+var lastUrl = location.href.replace(/\/[^\/]*$/,"\/010-2.html?1234");
parent.test(function () {
parent.assert_equals( httpReferer, lastUrl );
-}, 'HTTP Referer should use the pushed state (before onload)');
+}, "HTTP Referer should use the pushed state (before onload)");
parent.test(function () {
parent.assert_equals( document.referrer, lastUrl );
-}, 'document.referrer should use the pushed state (before onload)');
-try { history.pushState('','','010-4.html?2345'); } catch(e) {}
-location.href = '010-5.php';
+}, "document.referrer should use the pushed state (before onload)");
+try { history.pushState("","","010-4.html?2345"); } catch(e) {}
+location.href = "010-5.php";
</script>
</body>
-</html>
-'''
+</html>'
-#!/usr/bin/python
-
-import cgi
-import os
-referer = os.getenv("HTTP_REFERER")
-pyrefer = referer.encode()
-print "Content-type: text/html"
-form = '''
-<!doctype html>
+#!/bin/sh
+#
+referer="$HTTP_REFERER"
+echo "Content-type: text/html"
+echo
+form='<!doctype html>
<html>
<head>
<title>history.pushState/replaceState and referer headers (before onload)</title>
<noscript><p>Enable JavaScript and reload</p></noscript>
<div id="log"></div>
<script type="text/javascript">
-var pyreferer = "'''
-print form + pyrefer + '";'
-print '''
-var httpReferer = unescape(pyreferer);
-var lastUrl = location.href.replace(/\/[^\/]*$/,'\/010-4.html?2345');
+var pyreferer = "'
+echo "$form$referer\";"
+echo 'var httpReferer = unescape(pyreferer);
+var lastUrl = location.href.replace(/\/[^\/]*$/,"\/010-4.html?2345");
parent.test(function () {
parent.assert_equals( httpReferer, lastUrl );
-}, 'HTTP Referer should use the replaced state (before onload)');
+}, "HTTP Referer should use the replaced state (before onload)");
parent.test(function () {
parent.assert_equals( document.referrer, lastUrl );
-}, 'document.referrer should use the replaced state (before onload)');
+}, "document.referrer should use the replaced state (before onload)");
parent.done();
</script>
</body>
-</html>
-'''
+</html>'
+++ /dev/null
-#!/usr/bin/python
-#
-#Copyright (c) 2013 Intel Corporation.
-#
-#Redistribution and use in source and binary forms, with or without modification,
-#are permitted provided that the following conditions are met:
-#
-#* Redistributions of works must retain the original copyright notice, this list
-# of conditions and the following disclaimer.
-#* Redistributions in binary form must reproduce the original copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#* Neither the name of Intel Corporation nor the names of its contributors
-# may be used to endorse or promote products derived from this work without
-# specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
-#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-#ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
-#INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-#OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-#NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#Authors:
-# Lin, Wanming <wanmingx.lin@intel.com>
-
-import cgi
-import sys
-import os
-from os import environ
-
-def isset(variable):
- return variable in locals() or variable in globals()
-
-def include(filename):
- if os.path.exists(filename):
- execfile(filename)
-
-fields = cgi.FieldStorage()
-origin = "http://" + os.getenv("HTTP_HOST")
-credentials = "true"
-
-if isset(fields.getvalue('origin')):
- origin = fields.getvalue('origin')
-if isset(fields.getvalue('credentials')):
- credentials = fields.getvalue('credentials')
-
-print "Access-Control-Allow-Origin:" + origin
-
-if credentials != "none":
- print "Access-Control-Allow-Credentials:" + credentials
-
-run = fields.getvalue('run')
-
-if run in ["status-reconnect.php", "message.php", "redirect.php", "cache-control.php"]:
- include(run)
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
+MIME="text/event-stream"
+MESSAGE="data: data"
-import cgi
-import sys
-from os import environ
+val=`echo -n "$QUERY_STRING" | cgi-getfield mime`
+[ $? -eq 0 ] && MIME="$val"
-fields = cgi.FieldStorage()
-mime = "text/event-stream"
-message = "data: data"
-newline = "\n\n"
-
-if fields.getvalue('mime'):
- mime = str(fields.getvalue('mime'))
-
-if fields.getvalue('message'):
- message = str(fields.getvalue('message'))
-if fields.getvalue('newline'):
- if fields.getvalue('newline') == 'none':
- newline = ""
- else:
- newline = fields.getvalue('newline')
-
-print "Content-Type: %s" % mime
-print
-sys.stdout.write("%s%s" % (message, newline))
+echo "Content-Type: $MIME"
+echo
+val=`echo -n "$QUERY_STRING" | cgi-getfield message`
+if [ $? -eq 0 ]; then
+ echo -n "$QUERY_STRING" | cgi-getfield message
+ echo
+else
+ echo "data: data"
+fi
+val=`echo -n "$QUERY_STRING" | cgi-getfield newline`
+if [ $? -eq 0 -a "$val" = "none" ]; then
+ exit
+fi
+echo
+echo
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-
-import cgi
-import sys
-from os import environ
-
-fields = cgi.FieldStorage()
-id = "recon_fail_"
-if fields.getvalue('id'):
- id += str(fields.getvalue('id'))
-
-cookies = {}
-if environ.has_key('HTTP_COOKIE'):
- cookie_str = environ['HTTP_COOKIE']
- for cookie in cookie_str.split(';'):
- key, val = cookie.split('=')
- cookies[key.strip()] = val.strip()
-
-if not cookies.has_key(id):
- print "Status: 200 OPEN"
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s=opened" % id
- print
- print "retry: 500"
- print "data: opened\n"
-elif cookies[id] == "opened":
- print "Status: 200 RECONNECT"
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s=reconnected" % id
- print
- print "data: reconnected\n"
-elif cookies[id] == "reconnected":
- print "Status: 204 NO CONTENT (CLOSE)"
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s= " % id
- print
- print "data: closed\n"
-else:
- print "Status: 200 OPEN"
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s=opened" % id
- print
- print "retry: 500"
- print "data: opened\n"
+ID="recon_fail_"
+val=`echo -n "$QUERY_STRING"|cgi-getfield id`
+[ $? -eq 0 ] && ID="$ID$val"
+val=`echo -n "$HTTP_COOKIE" | cgi-getcookie $ID`
+if [ $? -ne 0 ]; then
+ echo "Status: 200 OPEN"
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $ID=opened"
+ echo
+ echo "retry: 500"
+ echo "data: opened"
+ echo
+elif [ "$val" = "opened" ]; then
+ echo "Status: 200 RECONNECT"
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $ID=reconnected"
+ echo
+ echo "data: reconnected"
+ echo
+elif [ "$val" = "reconnected" ]; then
+ echo "Status: 204 NO CONTENT (CLOSE)"
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $ID= "
+ echo
+ echo "data: closed"
+ echo
+else
+ echo "Status: 200 OPEN"
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $ID=opened"
+ echo
+ echo "retry: 500"
+ echo "data: opened"
+ echo
+fi
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-
-import cgi
-from os import environ
-
-fields = cgi.FieldStorage()
-status = "302"
-
-if fields.getvalue('status'):
- status = str(fields.getvalue('status'))
-
-print "Status: %s" % status
-print "Location: message.php"
-print "Content-Type: text/html"
-print
+STATUS="302"
+val=`echo -n "$QUERY_STRING" | cgi-getfield status`
+[ $? -eq 0 ] && STATUS="$val"
+echo "Status: $STATUS"
+echo "Location: message.php"
+echo "Content-Type: text/html"
+echo
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J<jing.j.wang@intel.com>
-
-import cgi
-
-fields = cgi.FieldStorage()
-status = "404"
-if fields.getvalue('status'):
- status = str(fields.getvalue('status'))
-
-print "Status: %s HAHAHAHA" % status
-print "Content-Type: text/event-stream"
-print
-print "data: data"
-print
+STATUS="404"
+val=`echo -n "$QUERY_STRING" | cgi-getfield status`
+[ $? -eq 0 ] && STATUS=$val
+echo "Status: $STATUS HAHAHAHA"
+echo "Content-Type: text/event-stream"
+echo
+echo "data: data"
+echo
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J<jing.j.wang@intel.com>
-import cgi
-import sys
-from os import environ
+STATUS="204"
+val=`echo -n "$QUERY_STRING" | cgi-getfield status`
+[ $? -eq 0 ] && STATUS="$val"
-fields = cgi.FieldStorage()
-status = "204"
-id = ""
-
-if fields.getvalue('status'):
- status = str(fields.getvalue('status'))
-
-if fields.getvalue('id'):
- id = str(fields.getvalue('id'))
-else:
- id = status
-
-cookies = {}
-if environ.has_key('HTTP_COOKIE'):
- cookie_str = environ['HTTP_COOKIE']
- for cookie in cookie_str.split(';'):
- key, val = cookie.split('=')
- cookies[key.strip()] = val.strip()
-
-query_str = environ.get('QUERY_STRING')
-req_id = "request%s" % id
-others = (not cookies.has_key(req_id)) | (not cookies.get(req_id) == status)
-if others:
- print "Status: %s TEST" % status
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s=%s" % (req_id, status)
- print
- print "retry: 200\n"
- if query_str and query_str.find("ok_first") >=0:
- print "data: ok\n"
-else:
- print "Content-Type: text/event-stream"
- print "Set-Cookie: %s=" % req_id
- print
- print "data: data\n"
+val=`echo -n "$QUERY_STRING" | cgi-getfield id`
+if [ $? -eq 0 ]; then
+ ID="$val"
+else
+ ID="$STATUS"
+fi
+REQID="request$ID"
+val=`echo -n "$HTTP_COOKIE" | cgi-getcookie $REQID`
+if [ $? -ne 0 -o ! "$val" = "$STATUS" ]; then
+ echo "Status: $STATUS TEST"
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $REQID=$STATUS"
+ echo
+ echo "retry: 200"
+ echo
+ val=`echo -n "$QUERY_STRING" | cgi-getfield ok_first`
+ if [ $? -eq 0 ]; then
+ echo "data: ok"
+ echo
+ fi
+else
+ echo "Content-Type: text/event-stream"
+ echo "Set-Cookie: $REQID="
+ echo
+ echo "data: data"
+ echo
+fi
+++ /dev/null
-<?php
- $origin = isset($_GET['origin']) ? $_GET['origin'] : $_SERVER['HTTP_ORIGIN'];
- header("Access-Control-Allow-Origin: $origin");
-
- $credentials = isset($_GET['credentials']) ? $_GET['credentials'] : "true";
- if ($credentials != "none")
- header("Access-Control-Allow-Credentials: $credentials");
-
- switch($_GET['run']) {
- case "status-reconnect.php":
- case "message.php":
- case "redirect.php":
- case "cache-control.php":
- include($_GET['run']);
- break;
- }
-?>
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-import cgi
-import sys
-from os import environ
+TAG=
+DATE=
-fields = cgi.FieldStorage()
+val=`echo -n "$QUERY_STRING" | cgi-getfield tag`
+[ $? -eq 0 ] && TAG="$val"
-ttag = ""
-ddate = ""
+val=`echo -n "$QUERY_STRING" | cgi-getfield date`
+[ $? -eq 0 ] && DATE="$val"
-if fields.getvalue('tag'):
- ttag = str(fields.getvalue('tag'))
+if [ -n "$TAG" -a "$HTTP_IF_NONE_MATCH" = "$TAG" ]; then
+ echo "Status: 304 SUPERCOOL"
+elif [ -n "$DATE" -a "$HTTP_IF_MODIFIED_SINCE" = "$DATE" ]; then
+ echo "Status: 304 SUPERCOOL"
+fi
-if fields.getvalue('date'):
- ddate = str(fields.getvalue('date'))
-
-if ttag and environ.get("HTTP_IF_NONE_MATCH", "") == ttag:
- print "Status: 304 SUPERCOOL"
-elif ddate and environ.get("HTTP_IF_MODIFIED_SINCE", "") == ddate:
- print "Status: 304 SUPERCOOL"
-
-if ddate:
- print "Last-Modified: %s" % ddate
-if ttag:
- print "ETag: %s" % ttag
-print "Content-Type: text/plain"
-print
-sys.stdout.write("MAYBE NOT")
+[ -n "$DATE" ] && echo "Last-Modified: $DATE"
+[ -n "$TAG" ] && echo "ETag: $TAG"
+echo "Content-Type: text/plain"
+echo
+echo -n "MAYBE NOT"
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-
-import cgi
-import sys
-import time
-
-fields = cgi.FieldStorage()
-
-delay = "500"
-if fields.getvalue('ms'):
- delay = str(fields.getvalue('ms'))
-time.sleep(int(delay)/1000)
-print "Content-Type: text/plain"
-print
-sys.stdout.write("TEST_DELAY")
+DELAY=500
+val=`echo -n "$QUERY_STRING" | cgi-getfield ms`
+[ $? -eq 0 ] && DELAY="$val"
+sleep `expr $DELAY / 1000`
+echo "Content-Type: text/plain"
+echo
+echo -n "TEST_DELAY"
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-
-import cgi
-import sys
-from os import environ
-
-def trans(v_str):
- if v_str in b_headers:
- return v_str.replace('-', '_')
- return "HTTP_" + v_str.replace('-', '_')
-
-fields = cgi.FieldStorage()
-
-filter_value = ""
-result = ""
-try:
- if fields.getvalue('filter_value'):
- filter_value = str(fields.getvalue('filter_value'))
-except:
- filter_value = "t1, t2"
-
-b_headers = ["CONTENT-TYPE"]
-headers = ["AUTHORIZATION", "PRAGMA", "CONTENT-TYPE", "OVERWRITE", "IF", "STATUS-URI", "X-TEST", "X-PINK-UNICORN"]
-
-for item in headers:
- if filter_value and (environ.get(trans(item), "") == filter_value):
- result = item.lower() + ","
- break
-
-print "Content-Type: text/plain"
-print
-sys.stdout.write(result)
+FILTER="t1, t2"
+RESULT=
+val=`echo -n "$QUERY_STRING" | cgi-getfield filter_value`
+[ $? -eq 0 ] && FILTER="$val"
+
+WLIST="CONTENT-TYPE"
+HEADERS="AUTHORIZATION PRAGMA CONTENT-TYPE OVERWRITE IF STATUS-URI X-TEST X-PINK-UNICORN"
+
+for item in $HEADERS; do
+ match=0
+ for i in $WLIST; do
+ if [ "$i" = "$item" ]; then
+ match=1
+ break
+ fi
+ done
+ key=${item//-/_}
+ [ $match -eq 0 ] && key="HTTP_$key"
+ val=`printenv $key`
+ if [ -n "$FILTER" -a "$val" = "$FILTER" ]; then
+ v=`echo "$item" | tr '[A-Z]' '[a-z]'`
+ RESULT="$v,"
+ break
+ fi
+done
+echo "Content-Type: text/plain"
+echo
+echo -n "$RESULT"
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-import cgi
-import sys
-from os import environ
+CODE=
+LOCATION=
+val=`echo "$QUERY_STRING" | cgi-getfield code`
+[ $? -eq 0 ] && CODE="$val"
-fields = cgi.FieldStorage()
+val=`echo "$QUERY_STRING" | cgi-getfield location`
+[ $? -eq 0 ] && LOCATION="$val"
-code = ""
-location = ""
+[ -n "$LOCATION" ] && LOCATION="$SCRIPT_NAME?followed"
-if fields.getvalue('code'):
- code = str(fields.getvalue('code'))
-
-if fields.getvalue('location'):
- location = str(fields.getvalue('location'))
-
-if not location:
- location = environ.get("SCRIPT_NAME", "") + "?followed"
-
-print "Status: %s WEBSRT MARKETING" % code
-print "Location: %s" % location
-print "Content-Type: text/plain"
-print
-print "TEST"
+echo "Status: $CODE WEBSRT MARKETING"
+echo "Location: $LOCATION"
+echo "Content-Type: text/plain"
+echo
+echo "TEST"
-#!/usr/bin/python
+#!/bin/sh
#
#Copyright (c) 2013 Intel Corporation.
#
#Authors:
# Wang, Jing J <jing.j.wang@intel.com>
-import cgi
-import sys
-from os import environ
+CODE="200"
+TEXT="OMG"
-fields = cgi.FieldStorage()
+val=`echo -n "$QUERY_STRING" | cgi-getfield code`
+[ $? -eq 0 ] && CODE="$val"
-code = "200"
-text = "OMG"
-content = ""
-ctype = ""
+val=`echo -n "$QUERY_STRING" | cgi-getfield text`
+[ $? -eq 0 ] && TEXT="$val"
-if fields.getvalue('code'):
- code = str(fields.getvalue('code'))
-
-if fields.getvalue('text'):
- text = str(fields.getvalue('text'))
-
-if fields.getvalue('content'):
- content = str(fields.getvalue('content'))
-
-if fields.getvalue('type'):
- ctype = str(fields.getvalue('type'))
-
-print "Status: %s %s" % (code, text)
-print "Content-Type: %s" % ctype
-print
-sys.stdout.write(content)
+echo "Status: $CODE $TEXT"
+echo "Content-Type: `echo -n "$QUERY_STRING" | cgi-getfield type`"
+echo
+echo -n "$QUERY_STRING" | cgi-getfield content