diff test/rest_common.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 c505c774a94d
children 576d630fc908
line wrap: on
line diff
--- a/test/rest_common.py	Tue Nov 30 00:21:55 2021 -0500
+++ b/test/rest_common.py	Wed Dec 01 19:52:54 2021 -0500
@@ -1180,8 +1180,8 @@
         each one broke and no etag. Use the put command
         to trigger the etag checking code.
         '''
-        for mode in ('header', 'etag', 'both',
-                     'brokenheader', 'brokenetag', 'none'):
+        for mode in ('header', 'header-gzip', 'etag', 'etag-br',
+                     'both', 'brokenheader', 'brokenetag', 'none'):
             try:
                 # clean up any old header
                 del(self.headers)
@@ -1198,9 +1198,17 @@
             if mode == 'header':
                 print("Mode = %s"%mode)
                 self.headers = {'if-match': etag}
+            elif mode == 'header-gzip':
+                print("Mode = %s"%mode)
+                gzip_etag = etag[:-1] + "-gzip" + etag[-1:]
+                self.headers = {'if-match': gzip_etag}
             elif mode == 'etag':
                 print("Mode = %s"%mode)
                 form.list.append(cgi.MiniFieldStorage('@etag', etag))
+            elif mode == 'etag-br':
+                print("Mode = %s"%mode)
+                br_etag = etag[:-1] + "-br" + etag[-1:]
+                form.list.append(cgi.MiniFieldStorage('@etag', br_etag))
             elif mode == 'both':
                 print("Mode = %s"%mode)
                 self.headers = {'etag': etag}
@@ -1216,7 +1224,7 @@
             elif mode == 'none':
                 print( "Mode = %s"%mode)
             else:
-                self.fail("unknown mode found")
+                self.fail("unknown mode '%s' found"%mode)
 
             results = self.server.put_attribute(
                 'user', self.joeid, 'realname', form

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