BaseHTTPServer and do_POST method

rocksportrocker rocksportrocker at googlemail.com
Wed Feb 27 07:33:35 EST 2008


Hi,

I am trying to implement a local server for storing and retrieving
numerical data.
So I use BaseHTTPServer as follows:

---------------------------------------------------------
    from BaseHTTPServer import *

    class Handler(BaseHTTPRequestHandler):

        def do_POST(self):

            print "POST"
            self.send_response(200)


    httpd = HTTPServer(("",8000), Handler)
    httpd.serve_forever()
---------------------------------------------------------

For testing I use:

---------------------------------------------------------

    import httplib


    data = "123456789o" * 100

    conn = httplib.HTTPConnection("localhost:8000")
    print conn.request("POST", "/", data)

---------------------------------------------------------------

Executing this client, the server says:

    error(10053, 'Software caused connection abort')

If I add "conn.getresponse()" at the end of the test script, the
message disapears, but the server hangs.

Where is my mistake ?

Greetings, Uwe.



More information about the Python-list mailing list