Opps, Graham you are right the iterator which I mentioned wouldn't be needed if all it did was create a list that got sent out. However, the PEP0333 also does have an example of an iterator in it done correctly.
How is not setting the Content-Length not taking advantage of HTTP/1.1 chunk encoding? Wouldn't, and this is an assumption, apache or whatever the server is add the chunk-size field to the header as explained in RFC2616 Chapter 3.6.1? ~Carl On Sun, Nov 14, 2010 at 9:50 PM, Graham Dumpleton <graham.dumple...@gmail.com> wrote: > On 15 November 2010 12:37, Carl Nobile <carl.nob...@gmail.com> wrote: >> This is really a WSGI question which is explained in the PEP 0333 spec below. >> >> http://www.python.org/dev/peps/pep-0333/ >> >> What you want to do uses the HTTP chunk response. > > Technically it is wrong to refer to it as chunked response as WSGI > specification doesn't deal with issue of chunked responses in as much > as that term is used in HTTP. > > Anyway, the short of it is that you should simply not set a > Content-Length response header. > > Rather than return an array of strings, you would use yield to return > successive blocks of data for the response. Alternatively, you write a > custom iterable with appropriate next() method for returning next > block of data. In other words, use a generator like object. > > You can find a lot of articles on WSGI referenced from: > > http://www.wsgi.org/wsgi/Learn_WSGI > > Graham > >> The spec shows how to write an iterator that creates a list that would >> be sent out. >> >> ~Carl >> >> On Sun, Nov 14, 2010 at 8:29 PM, Gelonida <gelon...@gmail.com> wrote: >>> Hi, >>> >>> I'd like to write an application, which generates https output of an >>> unkown length >>> >>> It will basically be a python function >>> yielding a number of strings. >>> >>> >>> What do I have to return as Content-Length ??? >>> >>> 0, >>> -1, >>> not send the Content-Length Header? >>> >>> something else? >>> >>> >>> Currently I have a wrapper function collecting the strings, calculation >>> their size and returning a list of all entries. >>> >>> Is ths really the only solution? >>> >>> >>> thanks in advance for suggestions / ideas >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "modwsgi" group. >>> To post to this group, send email to modw...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> modwsgi+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/modwsgi?hl=en. >>> >>> >> >> >> >> -- >> ------------------------------------------------------------------------------- >> Carl J. Nobile (Software Engineer) >> carl.nob...@gmail.com >> ------------------------------------------------------------------------------- >> >> -- >> You received this message because you are subscribed to the Google Groups >> "modwsgi" group. >> To post to this group, send email to modw...@googlegroups.com. >> To unsubscribe from this group, send email to >> modwsgi+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/modwsgi?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To post to this group, send email to modw...@googlegroups.com. > To unsubscribe from this group, send email to > modwsgi+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/modwsgi?hl=en. > > -- ------------------------------------------------------------------------------- Carl J. Nobile (Software Engineer) carl.nob...@gmail.com ------------------------------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to modw...@googlegroups.com. To unsubscribe from this group, send email to modwsgi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.