Infinite hangup when using CGI sys.stdin.read()

P

pacsciadmin

I maintain a CGI framework named PyTin, and while previously the
developer was only allowed to access GET and POST by cgi.FieldStorage.
I'm trying to add code to my request gatherer that looks like:

1. request.rawpost = StringIO() # Just normal StringIO
2. request.rawpost.write(sys.stdin.read())
3. request.rawpost.seek(0)
4. request.fields = cgi.FieldStorage(fp=request.rawpost)
5. request.rawpost.seek(0)

Obviously, my actual code doesn't have the line numbers.

I'm testing it out on the CGIHTTPRequestHandler with BaseHTTPServer,
and whenever my test script reaches line 2, it hangs up. It doesn't
spit out a traceback, or stop in less than a minute, whenever I use
sys.stdin.read(). Can anyone explain what is going on?

Regards,
LeafStorm
BDFL: Pacific Science
 
M

MRAB

I maintain a CGI framework named PyTin, and while previously the
developer was only allowed to access GET and POST by cgi.FieldStorage.
I'm trying to add code to my request gatherer that looks like:

1. request.rawpost = StringIO() # Just normal StringIO
2. request.rawpost.write(sys.stdin.read())
3. request.rawpost.seek(0)
4. request.fields = cgi.FieldStorage(fp=request.rawpost)
5. request.rawpost.seek(0)

Obviously, my actual code doesn't have the line numbers.

I'm testing it out on the CGIHTTPRequestHandler with BaseHTTPServer,
and whenever my test script reaches line 2, it hangs up. It doesn't
spit out a traceback, or stop in less than a minute, whenever I use
sys.stdin.read(). Can anyone explain what is going on?
sys.stdin.read() will read until EOF. If stdin is connected to a file
when the entire file will be read. If stdin is connected to the console
then it will return when it reaches the end of the input (will that ever
happen?) or the EOF marker, such as ctrl-Z in Windows or ctrl-D (I
think) in *nix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top