James Bennett wrote: > On Tue, Aug 4, 2009 at 11:54 AM, James Y Knight<f...@fuhm.net> wrote: >> But that works just fine today. Your WSGI app sends streaming data back >> using the iterator functionality, and the server automatically turns it into >> chunks if it's talking to an HTTP 1.1 client. What's the problem? > > No, it doesn't work just fine today. Either the server has to assume > that every response from that application should be chunked (which is > wrong), or the application needs a way to tell the server to chunk. > Turns out HTTP has a way to indicate that, but WSGI outright forbids > its use. So instead you have to invent out-of-band mechanisms for the > application to tell the server what to do, and in the process reinvent > part of HTTP.
It doesn't have to be out of band; CherryPy's wsgiserver will send a response chunked if the application provides no Content-Length response header. if status == 413: # Request Entity Too Large. Close conn to avoid garbage. self.close_connection = True elif "content-length" not in hkeys: # "All 1xx (informational), 204 (no content), # and 304 (not modified) responses MUST NOT # include a message-body." So no point chunking. if status < 200 or status in (204, 205, 304): pass else: if self.response_protocol == 'HTTP/1.1': # Use the chunked transfer-coding self.chunked_write = True self.outheaders.append(("Transfer-Encoding", "chunked")) else: # Closing the conn is the only way to determine len. self.close_connection = True Robert Brewer fuman...@aminus.org
_______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com