[Python-bugs-list] [Bug #122756] BaseHTTPServer subclass I/O call blocks forever

noreply@sourceforge.net noreply@sourceforge.net
Mon, 27 Nov 2000 13:13:14 -0800


Bug #122756, was updated on 2000-Nov-18 00:14
Here is a current snapshot of the bug.

Project: Python
Category: Library
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: BaseHTTPServer subclass I/O call blocks forever

Details: The following BaseHTTPServer subclass blocks in the do_POST() method under Python 2.0, 1.5.2 (on Windows NT and Linux) and JPython 1.1+09.  It seems to block in the write() calls after the read() call.




import BaseHTTPServer 
 
 
class VASTestHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): 
 
    contentType="text/html" 
 
    htmlForm="<FORM METHOD=POST ACTION=/handler>\r\n<br>NAME:&nbsp;<INPUT TYPE=\
TEXT NAME=name></INPUT><br><INPUT TYPE=SUBMIT></INPUT><p>\r\n</FORM>\r\n" 
    rspGETContent="<HTML>\r\n<HEAD>\r\n</HEAD>\r\n<BODY>\r\n<H1>GET</H1>\r\n%s<\
/BODY>\r\n</HTML>\r\n" 
 
    rspPOSTContent="\r\n\r\n<HTML>\r\n<HEAD>\r\n</HEAD>\r\n<BODY>\r\n<H1>POST</\
H1>\r\n%s</BODY>\r\n</HTML>\r\n" 
 
    def do_GET(self): 
        self.send_head() 
        self.wfile.write(self.rspGETContent % (self.htmlForm)) 
         
    def do_HEAD(self): 
        self.send_head() 
    def do_POST(self): 
        self.log_message("%s","Processing POST  ...") 
        self.log_message("%s",self.rspPOSTContent % (self.htmlForm)) 
        self.contentLength=int(self.headers.getheader("Content-Length")) 
        self.log_message("content-length=%d",self.contentLength) 
 
        # this read blocks forever 
        self.reqContent=self.rfile.read() 
        self.log_message("%s",self.reqContent) 
 
        self.send_head() 
        self.wfile.write(self.rspPOSTContent % (self.htmlForm)) 
        self.log_message("%s","Processed POST") 
         
    def send_head(self): 
        self.send_response(200) 
        self.send_header("Content-Type",self.contentType) 
        self.send_header("Expires","0") 
        self.end_headers() 
 
    def setContentType(self,type): 
        self.contentType=type 
 
 
def test(HandlerClass = VASTestHTTPRequestHandler, 
         ServerClass = BaseHTTPServer.HTTPServer): 
    port=8888 
    serverAddress=('',port) 
    httpd = ServerClass(serverAddress, HandlerClass) 
 
    print "Serving HTTP on port", port, "..." 
    httpd.serve_forever() 
 
 
if __name__ == '__main__': 
    test() 
 

Follow-Ups:

Date: 2000-Nov-27 13:13
By: gvanrossum

Comment:
As the author of said module I'll look at this.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=122756&group_id=5470