[Web-SIG] WSGI2: write callable?

PJ Eby pje at telecommunity.com
Sat Sep 27 21:43:20 CEST 2014


On Sat, Sep 27, 2014 at 2:55 PM, PJ Eby <pje at telecommunity.com> wrote:
> On Sat, Sep 27, 2014 at 12:20 AM, Robert Collins
<robertc at 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.)


More information about the Web-SIG mailing list