BaseHTTPServer weirdness

Ron Garret rNOSPAMon at flownet.com
Mon Sep 11 16:01:58 EDT 2006


In article <mailman.287.1158003082.5279.python-list at python.org>,
 Steve Holden <steve at holdenweb.com> wrote:

> The normal way is
> 
> s = cgi.parse()
> 
> since the CGI script sees the client network socket (after consumption 
> of HTTP headers) as its standard input.

Doesn't work.  (I even tried sys.stdin=r.rfile; s=cgi.parse())  Don't 
forget, this is not a CGI script, it's a handler for a BaseHTTPServer.


> > 2.  Despite the fact that I'm passing a 1 for the keep_blank_values 
> > argument to cgi.parse_qs, it doesn't actually keep blank values.  Is 
> > this a bug, or am I doing something wrong?
> > 
> Sounds like a bug, but then since your parsing looks buggy I'm surprised 
> you get anything at all. Try using a keyword argument 
> keep_blank_values=1 just in case the order has changed or something 
> daft. But fix your parsing first.
> 
> The other thing to note is that since you are putting a dictionary's 
> string representation out straight into your HTML if there are odd 
> characters in it this may give you strange output in the browser, so you 
> should view the page source to ensure that's not the case. Which it 
> probably isn't ...

I know that's not a problem because it does work when I use parse_qs.  
(I know about escaping HTML and all that, but this is just a little test 
program.)

rg



More information about the Python-list mailing list