Bizarre problem with HTTP POST verb and HTTPServer on Win32

mail.indigo.ie regkey at yahoo.com
Sat Sep 9 20:53:25 EDT 2000


Hi,

Something very weird is happening; I have written a simple subclass of
HTTPRequestHandler which should handle HTTP GET and HTTP POST.  It works
fine for HTTP GET but seems doesn't always respond to a POST on Win32.

If I create a form with method=POST and submit it then IE fails with
"connection reset by peer", curl (http://curl.haxx.nu) also fails.  It
looks like a problem with whatever the equivalent of SIGPIPE is on Win32:

administrator$ curl -i -d a=b localhost:6543
administrator$ curl -v -i -d a=b localhost:6543
* Connected to John Smart (127.0.0.1)
> POST / HTTP/1.0
User-Agent: curl/7.2 (win32) libcurl 7.2.1
Host: localhost:80
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
> Content-Length: 3
> Content-Type: application/x-www-form-urlencoded
> a=b

The source is simply:

import BaseHTTPServer

class MyHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

        def do_POST(this):
                this.do_GET()

        def do_GET(this):
                this.send_response(200)
                this.send_header("Content-type", "text/html")
                this.end_headers()
                this.wfile.write("Hello!\n")


svr = BaseHTTPServer.HTTPServer(('', 6543), MyHTTPRequestHandler)

print "listing on port 6543"

svr.serve_forever()


Has anyone got any idea what is going on?

Regards,

Niall Smart










More information about the Python-list mailing list