Hi,

I'm having a problem putting binary data into a body of http response
using twisted web.I'm doing something very wrong, any help is
appreciated. The funny thing is that it runs on python2.7, but fails
on python2.5. Most probably it has something to do with unicode/str.

Code snipplet:
-------
def render_GET(self, request):
    # get contents of a binary file, e.g. zip archive
    request.setHeader('Content-type', 'some-mime')
    return content
-----

This results in a error:
....
          File 
"C:\Python25\lib\site-packages\twisted\internet\selectreactor.py",
line 146, in _doReadOrWrite
            why = getattr(selectable, method)()
          File "C:\Python25\lib\site-packages\twisted\internet\tcp.py",
line 428, in doWrite
            result = abstract.FileDescriptor.doWrite(self)
          File "C:\Python25\lib\site-packages\twisted\internet\abstract.py",
line 199, in doWrite
            self.dataBuffer = buffer(self.dataBuffer, self.offset) +
"".join(self._tempDataBuffer)
        exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte
0x92 in position 10: ordinal not in range(128)

Any ideas? I assumed that I can put any contents into http body.

thanks,
Ilja

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to