Re: WSGI2: write callable?

PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> Sat, 27 Sep 2014 15:43:20 -0400
Newsgroups gmane.comp.python.web
Message-ID <CALeMXf44ua5HqmCDvo6vJuAxLg7Y45XYOpgoE4VsGLn55KKhfA@mail.gmail.com>
On Sat, Sep 27, 2014 at 2:55 PM, PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote:
> On Sat, Sep 27, 2014 at 12:20 AM, Robert Collins
<[email protected]> 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
[email protected]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: https://mail.python.org/mailman/options/web-sig/gcpw-web-sig%40m.gmane.org