gholt/brim — pull request #8 by ahale (2012-12-23 10:39:49+00:00)
Title: Add support for defining chunked transfer minimum chunk size

Added a small change to allow configurable HTTP chunk size when serving chunked transfer encoded data. Eventlet allows this but seems to default to 4096 byte chunks.

This causes problems with long running requests using a generator which, rather than yielding large chunks of large files, instead generates short intermittent messages such as this EventSource stream.

$ curl -D - http://127.0.0.1/events/
HTTP/1.1 200 OK
Date: Sun, 23 Dec 2012 09:33:19 GMT
Content-Type: text/event-stream
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache

data: {"a": 2, "timestamp": 1356255200}

data: {"a": 3, "timestamp": 1356255220}

data: {"a": 5, "timestamp": 1356255225}

With the default chunk size these messages will buffer until there is a full chunk to send - resulting in a whole bunch at once. Dropping the minimum chunk size lets these come through as expected.

While my use case does kinda seem like a blatant disregard for the buffering and streaming part of PEP333 it still feels a reasonable/useful parameter in eventlet.wsgi.server to expose and the default setting doesn't change existing behaviour...