From 770ecc8d3272f68630cacb5a3b8b7fe96ed39176 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 9 Jul 2003 09:37:12 +0000
Subject: [PATCH] Changes necessary for CGI execution (via jsexec).

---
 exec/nodelist-html.js | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/exec/nodelist-html.js b/exec/nodelist-html.js
index 0b63975e97..de91f1562d 100644
--- a/exec/nodelist-html.js
+++ b/exec/nodelist-html.js
@@ -28,15 +28,18 @@ for(i=0;i<argc;i++)
 			break;
 	}
 
-// Write a string to the client socket
-function write(str)
-{
-	client.socket.send(str);
-}
+if(this.server!=undefined) {
 
-function writeln(str)
-{
-	write(str + "\r\n");
+	// Write a string to the client socket
+	function write(str)
+	{
+		client.socket.send(str);
+	}
+
+	function writeln(str)
+	{
+		write(str + "\r\n");
+	}
 }
 
 function xtrn_name(code)
@@ -52,8 +55,8 @@ function xtrn_name(code)
 }
 
 // Get HTTP Request
-while(client.socket.data_waiting) {
-	request = client.socket.recvline(128 /*maxlen*/, 3 /*timeout*/);
+while(this.client!=undefined && client.socket.data_waiting) {
+	request = client.socket.recvline(512 /*maxlen*/, 3 /*timeout*/);
 
 	if(request==null) 
 		break;
@@ -61,6 +64,10 @@ while(client.socket.data_waiting) {
 //	log(format("client request: '%s'",request));
 }
 
+if(this.server==undefined) {	/* CGI, so send CGI/HTTP headers */
+	writeln("Content-Type: text/html");
+	writeln();
+}
 // HTML Header
 writeln("<html>");
 writeln("<head>");
-- 
GitLab