BaseHTTPServer and do_POST method

7stud bbxx789_05ss at yahoo.com
Wed Feb 27 08:50:35 EST 2008


On Feb 27, 5:33 am, rocksportrocker <rocksportroc... at googlemail.com>
wrote:
> 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.

I don't get that error.  On the server, I get the output:

POST
localhost - - [27/Feb/2008 06:49:13] "POST / HTTP/1.1" 200 -

and on the client I get:

None

I don't know what's causing the second line of output on the server.



More information about the Python-list mailing list