Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > getting POST vars from BaseHTTPRequestHandler

Thread Tools

getting POST vars from BaseHTTPRequestHandler

Christopher J. Bottaro
Posts: n/a

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 'no data'

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


When I make a post, it just hangs (in

Thanks for the help.

Reply With Quote
Posts: n/a
Christopher J. Bottaro wrote:

> When I make a post, it just hangs (in

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
(E-Mail Removed)

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use self.vars in class.method(parameters, self.vars) caccolangrifata Python 18 07-22-2011 10:22 PM
How do I declare global vars or class vars in Python ? Linuxguy123 Python 7 02-20-2009 06:45 PM
BaseHTTPServer.BaseHTTPRequestHandler and HTTP chunking Andy Leszczynski Python 2 03-10-2005 05:27 PM
app vars and cache vars Jon ASP .Net 3 12-14-2004 08:52 PM
BaseHTTPRequestHandler - bypassing browser cache Ben Python 2 10-19-2003 07:16 AM