How do I return binary data from a python CGI called from CGIHTTPServer?
Mark Wright
mwright at pro-ns.net
Tue Jun 5 15:30:58 EDT 2001
"Alex Martelli" <aleaxit at yahoo.com> wrote in message news:<9f96kb01mq8 at enews1.newsguy.com>...
> "Mark Wright" <mwright at pro-ns.net> wrote in message
> news:f9ff3f62.0106011427.6243e5e9 at posting.google.com...
> ...
> > But my original problem/question remains: how does a CGI program
> > return binary data on windows? Is it even possible? The problem is
>
> python.exe must be run with option -u, to have binary standard input
> and output streams, rather than text ones as it has by default.
>
>
> Alex
This works correctly for 0x0a, but it still gets upset about 0x1a -
a.k.a. ctrl-Z, a.k.a. end of file. If there's a ctrl-z in the output
of my CGI script CGIHTTPServer truncates the data.
At this point, I've given up using the standard CGIHTTPServer. I've
created a modified version that runs python scripts inline, rather
than forking (well, popening - I'm on Win2k) a new process and piping
the output back to the client. Problem solved.
Still, others out there must be returning binary data from a CGI
script on NT/2000, right? How are they doing it?
Mark
More information about the Python-list
mailing list