'We must case-mangle the Set-Cookie header name or AWS will use only a
single one of these headers.'

def __call__(self, environ, start_response):

    def encode_response(status, headers, exc_info=None):
        '\n                                                Create    an    APIGW-acceptable    version    of    our    cookies.\n\n                                                We    have    to    use    a    bizarre    hack    that    turns    multiple    Set-Cookie    headers    into\n                                                their    case-permutated    format,    ex:\n\n                                                Set-cookie:\n                                                sEt-cookie:\n                                                seT-cookie:\n\n                                                To    get    around    an    API    Gateway    limitation.\n\n                                                This    is    weird,    but    better    than    our    previous    hack    of    creating    a    Base58-encoded\n                                                supercookie.\n                                                '
        new_headers = [header for header in headers if ((type(header[0]) != str) or (header[0].lower() != 'set-cookie'))]
        cookie_headers = [header for header in headers if ((type(header[0]) == str) and (header[0].lower() == 'set-cookie'))]
        for (header, new_name) in zip(cookie_headers, all_casings('Set-Cookie')):
            new_headers.append((new_name, header[1]))
        return start_response(status, new_headers, exc_info)
    response = self.application(environ, encode_response)
    return ClosingIterator(response)
