Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created April 18, 2011 20:59
Show Gist options
  • Select an option

  • Save jacobian/926162 to your computer and use it in GitHub Desktop.

Select an option

Save jacobian/926162 to your computer and use it in GitHub Desktop.

Revisions

  1. jacobian created this gist Apr 18, 2011.
    21 changes: 21 additions & 0 deletions chunked.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #
    # Run this under your WSGI server, and then try
    #
    # curl -N -i <server>
    #
    # If you're chunked, you should see the pause between "hello" and "world".

    import time

    def application(environ, start_response):
    """Simplest possible application object"""
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)

    def resp():
    yield "hello "
    time.sleep(1)
    yield "world!\n"

    return resp()