

def encode_response(self, status, headers, exc_info=None):
    '\n        Zappa-ify our application response!\n\n        This means:\n            - Updating any existing cookies.\n            - Packing all our cookies into a single ZappaCookie.\n            - Injecting redirect HTML if setting a Cookie on a redirect.\n\n        '
    new_headers = [(header[0], header[1]) for header in headers if (header[0] != 'Set-Cookie')]
    cookie_dicts = [{
        header[1].split('=', 1)[0].strip(): header[1].split('=', 1)[1:][0],
    } for header in headers if (header[0] == 'Set-Cookie')]
    new_cookies = dict()
    map(new_cookies.update, cookie_dicts)
    for (name, value) in new_cookies.items():
        self.request_cookies[name] = value
    expires = None
    for (name, value) in self.request_cookies.items():
        cookie = ((name + '=') + value).encode('utf-8')
        if (cookie.count('=') is 1):
            continue
        kvps = cookie.split(';')
        for kvp in kvps:
            kvp = kvp.strip()
            if ('expires' in kvp.lower()):
                exp = time.strptime(kvp.split('=')[1], '%a, %d-%b-%Y %H:%M:%S GMT')
                if (exp > expires):
                    expires = exp
                break
    pack_s = json.dumps(self.request_cookies)
    encoded = base58.b58encode(pack_s)
    new_headers.append(('Set-Cookie', dump_cookie('zappa', value=encoded, expires=expires)))
    if (status != '200 OK'):
        for (key, value) in new_headers:
            if (key != 'Location'):
                continue
            self.redirect_content = REDIRECT_HTML.replace('REDIRECT_ME', value)
            status = '200 OK'
            break
    return self.start_response(status, new_headers, exc_info)

dataset/ETHPy150Open Miserlou/Zappa/zappa/middleware.py ZappaWSGIMiddleware.encode_response/original