I have a large amount of data that I'm attempting to stream through
pylons. This data is created via another library on the fly and does
not exist on disk. Because I don't want to read all of the data into
memory at once, I'm using a generator in my controller to stream small
chunks off at a time. This is easy to do in pylons and works quite
well:

class StreamController(BaseController):
    def stream(self):
        bigdata = MyBigDataStore()
        def do_it():
            while True:
                buf = bigdata.getchunk()
                if buf:
                    yield buf
                else:
                    break
        return do_it()

The only problem I have is the user does not get a progress bar when
downloading this data, even though I know exactly how much data I'm
sending them, because there is no Content-Length header sent to the
client. I thought this would be as simple as specifying:

response.headers['Content-Length'] = "12345"

However, it seems that pylons is trying to outsmart me, because every
time I try that it deletes that header from the response. Apparently I
can create other headers eg. "X-Real-Content-Length" works just fine,
but "Content-Length" is removed every time.

Do I need to mess around with BaseController and somehow reinstate the
missing header?

FYI, I'm using pylons 0.9.7. Thanks to anyone who can help :)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to