Joined: 15 Apr 2011
|Posted: Mon May 07, 2012 2:12 pm Post subject: CGIHTTPRequestHandler unusable on VMS?
|Using the most basic example, in accordance to my experience and knowledge of Python, I found the CGIHTTPRequestHandler isn't working on OpenVMS for a number of reasons.
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
- The CGIHTTPRequestHandler assumes that commandlines are of the
format <name of executable> <arguments>. This does not apply to VMS.
- After tweaking CGIHTTPServer.py to at least run python programs
| if self.is_python(scriptfile):
#interp = sys.executable
interp = "python" #VMS
there is a problem with popen2: by default, this is called in binary mode,
but then, all linefeeds and carriage returns are stripped from the python script's output by popen2. Using this dumb example in a cgi-bin subdrectory, this is easily demonstrated:
|testdoc = """<html><body>\n\n
Where are my line feeds?</body></html>\n\n"""
print "Content-type: text/plain\r\n\r\n"
The result is an empty reply and/or a hanging client.
A telnet to the server port demonstrates this too:
|$ telnet localhost 8888
%TELNET-I-TRYING, Trying ... 127.0.0.1
%TELNET-I-SESSION, Session 01, host localhost, port 8888
GET /cgi-bin/y.py HTTP/1.0haracter is ^]
HTTP/1.0 200 Script output follows
Server: SimpleHTTP/0.6 Python/2.5.4
Date: Mon, 07 May 2012 12:04:19 GMT
%TELNET-S-REMCLOSED, Remote connection closededs?</body></html>
-TELNET-I-SESSION, Session 01, host localhost, port 8888
You can just see the tail of the script output being overwritten by the telnet
- Am I doing something wrong?
- Am I expecting too much?
- Shouldn't I bother and not even think of using this?
- Is this a bug?