On Sat, Sep 27, 2014 at 2:55 PM, PJ Eby <p...@telecommunity.com> wrote: > On Sat, Sep 27, 2014 at 12:20 AM, Robert Collins <robe...@robertcollins.net> wrote: >> Right now, anything providing the server profile has to cope with >> exceptions and translate those to 500 errors, so we have the variation >> of 'status and headers may not be provided'. Most middleware can be >> oblivious and delegate this to the server via bubble-up. I suspect the >> same would work for a default of 200 - 99% of middleware would ignore >> it and it would just work. However, I'm not super attached - it was >> just an idea. > > In the limit case, > >> >>>> So a classic example for Trailers is digitally signing streamed >>>> content. Using the same strawman API as above: >>>> >>>> def app(environ): >>>> yield {':status': '200} >>>> md5sum = md5.new() >>>> for bytes in block_reader(open('foo', 'rb'), 65536): >>>> md5sum.update(bytes) >>>> yield bytes >>>> digest = md5sum.hexdigest() >>>> signature = sign_bytes(digest.encode('utf8')) >>>> yield {'Content-MD5Sum': digest, 'X-Signature': signature} >>>> >>>> Note that this doesn't need to buffer or use a closure.
(Oops. The above was some stuff I forgot to delete while editing.) _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: https://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com