creating tar file and streaming it over HTTP?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Jan 7 06:09:53 EST 2010


En Wed, 06 Jan 2010 13:39:08 -0300, pbienst <peter.bienstman at gmail.com>  
escribió:

> The problem seems to be that the
> receiving end (wsgi server) does not see the end of the data:
>
>             socket = environ["wsgi.input"]
>             while True:
>                 sys.stderr.write("before")
>                 chunk = socket.read(4096)
>                 sys.stderr.write("after")
>                 if not chunk:
>                     sys.stderr.write("done")
>                     break
>                 sys.stderr.write(chunk)
>
> There is data from the tar file being printed, but in the end it hangs
> in the 'before' statement, and never gets to 'done'. I tried flushing
> the fileobj created by makefile(), but that doesn't seem to help.
> There is also no environ["CONTENT_LENGTH"] that I can use to detect
> the end of the stream.
>
> I'm probably missing something basic here...

Either send a "Connection: Close" header (and close the connection at the  
end), or a "Transfer-Encoding: chunked" header (see  
http://en.wikipedia.org/wiki/Chunked_transfer_encoding )

-- 
Gabriel Genellina




More information about the Python-list mailing list