Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

getting POST vars from BaseHTTPRequestHandler

 
 
Christopher J. Bottaro
Guest
Posts: n/a
 
      06-26-2006
Hi,

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

<code>

class MyHandler(BaseHTTPRequestHandler):

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

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

</code>

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

Thanks for the help.

 
Reply With Quote
 
 
 
 
and-google@doxdesk.com
Guest
Posts: n/a
 
      06-28-2006
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
(E-Mail Removed)
http://www.doxdesk.com/

 
Reply With Quote
 
 
 
Reply

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



Advertisments