Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

BaseHTTPServer - getting POST parameters

已查看 29 次
跳至第一个未读帖子

Vlad Dogaru

未读,
2006年11月14日 16:00:352006/11/14
收件人
Hello,

After experimenting for a while, I am still not able to find where the
POST data is in the BaseHTTPRequestHandler class. I am trying to write
a very simple HTTP server for a project of mine and I need to get the
POST data. Certainly I am missing something, as it is a comon task.

Thanks in advance,
Vlad

Paul Boddie

未读,
2006年11月14日 16:36:412006/11/14
收件人

The way I've done this previously is to access the rfile attribute on
instances of the BaseHTTPRequestHandler class, since this provides the
body of each request (where POST data comes from) as a stream. Data
read from the stream can be processed by things like cgi.parse or
cgi.FieldStorage, although you may need to provide other data to those
things in order to simulate the CGI environment properly.

An alternative is to use WebStack's BaseHTTPRequestHandler support:

http://www.python.org/pypi/WebStack

Paul

Fredrik Lundh

未读,
2006年11月14日 16:43:042006/11/14
收件人 pytho...@python.org
Vlad Dogaru wrote:

it's nowhere: you're supposed to read it from the socket via the "rfile"
attribute.

</F>

0 个新帖子