Streaming in WSGI is usually done by passing a generator function as a response. As HTTPResponse.write only accepts str and bytes, I tried this:
def hello(): yield b'hello' time.sleep(1) yield b'world' resp = wheezy.http.HTTPResponse() resp.buffer = hello() return resp
But this doesn't work, because HTTPResponse tries to calculate the length of the response, which is needed to emit the Content-Length header. So, I suggest:
- There needs to be some ways to disable emitting the header, by making an option, or by adding a subclass.
- HTTPResponse should also provide a method to replace its buffer. The direct assignment to HTTPResponse.buffer seems to be inconsistent with other methods it provides(write, write_bytes).