forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CGIHTTPRequestHandler unusable on VMS?

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
joseb



Joined: 15 Apr 2011
Posts: 4

PostPosted: Mon May 07, 2012 2:12 pm    Post subject: CGIHTTPRequestHandler unusable on VMS? Reply with quote

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.
Code:
server_address=('localhost',8888)
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
Code:
            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:

Code:
testdoc = """<html><body>\n\n
<h1>Huh?</h1>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Where are my line feeds?</body></html>\n\n"""

print "Content-type: text/plain\r\n\r\n"
print
print testdoc


The result is an empty reply and/or a hanging client.
A telnet to the server port demonstrates this too:

Code:
$ 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
REMCLOSED message.

My questions:
- 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?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group