diff roundup/cgi/client.py @ 6539:f8df7fed18f6

issue2551175 - Make ETag content-encoding aware. HTTP ETag headers now include a suffix (-gzip, -br, -zstd) indicating the content-encoding used to send the data per rfc7232. Validate any form of ETag by stripping a suffix (if present).
author John Rouillard <rouilj@ieee.org>
date Wed, 01 Dec 2021 19:52:54 -0500
parents 1fc765ef6379
children 9aa8df0b4426
line wrap: on
line diff
--- a/roundup/cgi/client.py	Tue Nov 30 00:21:55 2021 -0500
+++ b/roundup/cgi/client.py	Wed Dec 01 19:52:54 2021 -0500
@@ -2166,6 +2166,14 @@
             self.additional_headers['Content-Length'] = str(len(new_content))
             self.additional_headers['Content-Encoding'] = encoder
             self.setVary('Accept-Encoding')
+            try:
+                current_etag = self.additional_headers['ETag']
+            except KeyError:
+                pass  # etag not set for non-rest endpoints
+            else:
+                etag_end = current_etag.rindex('"')
+                self.additional_headers['ETag'] = ( current_etag[:etag_end] +
+                                    '-' + encoder + current_etag[etag_end:])
 
         return new_content
 

Roundup Issue Tracker: http://roundup-tracker.org/