468,761 Members | 1,759 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,761 developers. It's quick & easy.

getting POST vars from BaseHTTPRequestHandler


I can't for the life of me figure out how to get the post vars when using
basehttpserver. Here's my code:


class MyHandler(BaseHTTPRequestHandler):

def do_POST(self):
print self.path, self.command
if self.rfile:
print self.rfile.read()
print 'no data'

server = HTTPServer(('', 80), MyHandler)


When I make a post, it just hangs (in self.rfile.read()).

Thanks for the help.

Jun 26 '06 #1
1 6455
Christopher J. Bottaro wrote:
When I make a post, it just hangs (in self.rfile.read()).

I don't know about BaseHTTPRequestHandler in particular, but in general
you don't want to call an unlimited read() on an HTTP request - it will
try to read the entire incoming stream, up until the stream is ended by
the client dropping the connection (by which point it's too late to
send a response).

Instead you'll normally want to read the request's Content-Length
header (int(os.environ['CONTENT_LENGTH']) under CGI) and read(that
many) bytes.

And Clover

Jun 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gerard van Wilgen | last post: by
reply views Thread by Lucas Branca | last post: by
2 posts views Thread by Andy Leszczynski | last post: by
14 posts views Thread by pl | last post: by
5 posts views Thread by David Rasmussen | last post: by
10 posts views Thread by glenn | last post: by
4 posts views Thread by Sylvain Girard | last post: by
2 posts views Thread by Vlad Dogaru | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.