Index: tools/gformat.py
===================================================================
--- tools/gformat.py	(revision 11426)
+++ tools/gformat.py	(revision 11427)
@@ -1135,6 +1135,6 @@
 
   # Update repository if requested
-  form = urlparse.parse_qs(environ['QUERY_STRING'])
-  if form.has_key("action") and "update" in form["action"]:
+  form = urlparse.parse_qs(environ['QUERY_STRING']) if environ.has_key('QUERY_STRING') else None
+  if form and form.has_key("action") and "update" in form["action"]:
     output = "[INFO] Updating subverion, please wait...\n"
     output += subprocess.Popen(['svn', 'cleanup', "%s/.." % NODE_DIR], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
@@ -1454,4 +1454,15 @@
       print "#ERROR: '%s' is invalid input (left, right, edit or ignore)!" % c
 
+
+
+def print_cgi_response(response_headers, output):
+  """Could we not use some kind of wsgi wrapper to make this output?"""
+  for header in response_headers:
+     print "%s: %s" % header
+  print "\n"
+  print output
+
+
+
 def main():
   """Hard working sub"""
@@ -1515,5 +1526,6 @@
       os.environ['PATH_INFO'] = "/".join(sys.argv[2:])
       os.environ['SCRIPT_NAME'] = __file__
-      process_cgi_request()
+      response_headers, output = process_cgi_request()
+      print_cgi_response(response_headers, output)
     elif sys.argv[1] == "static":
       items = dict()
@@ -1869,5 +1881,6 @@
     if not is_text_request():
       cgitb.enable()
-    process_cgi_request()
+    response_headers, output = process_cgi_request()
+    print_cgi_response(response_headers, output)
 
 def application(environ, start_response):
