W
Walter Huf
Okay, I'm busy making a wonderful cgi program, and everything is working
wonderfully so far. I'm using the standard cgi library and the Cookie
library and they have been a huge help. Thanks to those who have created
them!
However, if I try to send binary data, like jpgs, through cgi, the data
gets corrupted in a very small manner. Whenever my program sends the
character 10, it gets converted to character 13+character 10. I found out
this only happens when I send data to stdout. If I send the data to a
standard file object, it works fine. However, with the stdout, the problem
arises.
Here is the relevant part of the code:
---Begin
from sys import stdout
def senddownloaddata(file): #file is a pointer to an open file
line=file.read(1) #file pointer opening and closing are
while len(line)==1: # handled outside of function
stdout.write(line)
line=file.read(1)
stdout.write(line)
---End
Now the code that copies files:
---Begin
curdir="C:\windows\desktop"
temp=file(curdir+"/bach.it","rb",0)
out=file(curdir+"/bach2.it","wb",0)
data=temp.read(1)
while len(data)==1:
out.write(data)
data=temp.read(1)
temp.close()
out.close()
---End
I'm using Windows 98 SE with an Apache 2.0.44 Win32 server. That all works
fine. The first line of the interactive script says:
PythonWin 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32.
I'm assuming that means I have Python 2.3.2. Everything else in the program
works very nice, except for the data corruption.
Please help me with this problem. It has me stumped.
Thanks in advance!
--Walter Huf--
(e-mail address removed)
wonderfully so far. I'm using the standard cgi library and the Cookie
library and they have been a huge help. Thanks to those who have created
them!
However, if I try to send binary data, like jpgs, through cgi, the data
gets corrupted in a very small manner. Whenever my program sends the
character 10, it gets converted to character 13+character 10. I found out
this only happens when I send data to stdout. If I send the data to a
standard file object, it works fine. However, with the stdout, the problem
arises.
Here is the relevant part of the code:
---Begin
from sys import stdout
def senddownloaddata(file): #file is a pointer to an open file
line=file.read(1) #file pointer opening and closing are
while len(line)==1: # handled outside of function
stdout.write(line)
line=file.read(1)
stdout.write(line)
---End
Now the code that copies files:
---Begin
curdir="C:\windows\desktop"
temp=file(curdir+"/bach.it","rb",0)
out=file(curdir+"/bach2.it","wb",0)
data=temp.read(1)
while len(data)==1:
out.write(data)
data=temp.read(1)
temp.close()
out.close()
---End
I'm using Windows 98 SE with an Apache 2.0.44 Win32 server. That all works
fine. The first line of the interactive script says:
PythonWin 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32.
I'm assuming that means I have Python 2.3.2. Everything else in the program
works very nice, except for the data corruption.
Please help me with this problem. It has me stumped.
Thanks in advance!
--Walter Huf--
(e-mail address removed)