This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nobody
Recipients
Date 2000-11-18.08:14:12
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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() 
 
History
Date User Action Args
2007-08-23 13:52:13adminlinkissue222756 messages
2007-08-23 13:52:13admincreate