doc: Documented htpipe.
[ashd.git] / python / htredir
index 1a54bee..1e03499 100755 (executable)
@@ -31,8 +31,8 @@ if len(args) != 4:
     usage(sys.stderr)
     sys.exit(1)
 target, method, url, rest = args
-scheme = os.getenv("HTTP_X_ASH_PROTOCOL")
-host = os.getenv("HTTP_HOST")
+scheme = os.getenv("REQ_X_ASH_PROTOCOL")
+host = os.getenv("REQ_HOST")
 me = url
 if me[-len(rest):] == rest:
     me = me[:-len(rest)]
@@ -53,7 +53,10 @@ else:
     # Illegal, but the only option (the premises are illegal anyway)
     pass
 
-sys.stdout.write("HTTP/1.1 %s\n" % status)
-sys.stdout.write("Location: %s\n" % target)
-sys.stdout.write("Content-Length: 0\n")
-sys.stdout.write("\n")
+try:
+    sys.stdout.write("HTTP/1.1 %s\n" % status)
+    sys.stdout.write("Location: %s\n" % target)
+    sys.stdout.write("Content-Length: 0\n")
+    sys.stdout.write("\n")
+except IOError:
+    sys.exit(1)