Allow additions to auto-generated xkey tags
authorMagnus Hagander <magnus@hagander.net>
Mon, 23 Nov 2020 10:57:40 +0000 (11:57 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 23 Nov 2020 10:58:51 +0000 (11:58 +0100)
If an xkey tag is already set on a response when it reaches the
middleware, add it to the set of automated xkeys generated from the
templates instead of overwriting it.

pgweb/util/middleware.py

index acbb7f3f64fb1f4ae9ed65c1ed3d629490175576..1609e00174a248d44ae7eb395ce98429bc033ce6 100644 (file)
@@ -40,7 +40,7 @@ class PgMiddleware(object):
             response['x-do-esi'] = "1"
             tlist.remove('base/esi.html')
         if tlist:
-            response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t.encode('ascii', errors='replace')).hexdigest()) for t in tlist])
+            response['xkey'] = ' '.join(["pgwt_{0}".format(hashlib.md5(t.encode('ascii', errors='replace')).hexdigest()) for t in tlist] + [response.get('xkey', '')])
 
         # Set security headers
         sources = OrderedDict([