NGSegovia / wsgi-intercept

Automatically exported from code.google.com/p/wsgi-intercept
Other
0 stars 0 forks source link

wsgi_intercept can't handle functions that stream chunked encoding data infinitely #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a WSGI application that returns an iterator that streams infinitely.
2. Try to test the WSGI application.

What is the expected output?
It'd be great if it could give you an iterator.

What do you see instead?
It tries to buffer everything.

What version of the product are you using?
0.4

On what operating system?
Linux jjinux 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 02:41:37 UTC 2010 
x86_64 GNU/Linux

Please provide any additional information below.
A WSGI application can return an iterator.  It knows how to output things using 
a chunked encoding.  That's useful to stream a possibly infinite amount of 
data.  My application is like that.  Unfortunately, this is not currently 
supported by wsgi_intercept.

I ended up using WebOb to test my application:

        request = webob.Request.blank('/')
        response = request.get_response(server.Handler.handle)
        assert response.app_iter.next() == "\n"
        assert response.app_iter.next() == '{"test": "data"}\n'

Original issue reported on code.google.com by jji...@gmail.com on 26 Jan 2011 at 2:29

GoogleCodeExporter commented 8 years ago
Would it be easy to attach a simple wsgi app that I could use to reproduce 
this?  Or perhaps link to the source code of one.

Original comment by kumar.mcmillan on 26 Jan 2011 at 3:21

GoogleCodeExporter commented 8 years ago
Perhaps something like this:

def application(environ, start_response):
    start_response("200 OK", [('Content-type', 'text/plain')])

    def response():
        yield "hi\n"

    return iter(response())

Original comment by jji...@gmail.com on 31 Mar 2011 at 12:22