Add default support for optimistic concurrency on PATCH requests
diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py
index 64f2e17..1e6a5c0 100644
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -865,7 +865,7 @@
 
         # Which HTTP methods do we apply optimistic concurrency to, i.e.
         # which methods get an "if-match:" etag header added to them.
-        self.optimistic_concurrency_methods = ["PUT"]
+        self.optimistic_concurrency_methods = ["PUT", "PATCH"]
 
         # If 'follow_redirects' is True, and this is set to True then
         # all redirecs are followed, including unsafe ones.
diff --git a/python2/httplib2test.py b/python2/httplib2test.py
index d4c46cc..e505150 100755
--- a/python2/httplib2test.py
+++ b/python2/httplib2test.py
@@ -882,7 +882,7 @@
         self.assertEqual(response.fromcache, False)
 
     def testUpdateUsesCachedETag(self):
-        # Test that we natively support http://www.w3.org/1999/04/Editing/ 
+        # Test that we natively support http://www.w3.org/1999/04/Editing/
         uri = urlparse.urljoin(base, "conditional-updates/test.cgi")
 
         (response, content) = self.http.request(uri, "GET")
@@ -896,6 +896,22 @@
         (response, content) = self.http.request(uri, "PUT", body="foo")
         self.assertEqual(response.status, 412)
 
+    def testUpdatePatchUsesCachedETag(self):
+        # Test that we natively support http://www.w3.org/1999/04/Editing/
+        uri = urlparse.urljoin(base, "conditional-updates/test.cgi")
+
+        (response, content) = self.http.request(uri, "GET")
+        self.assertEqual(response.status, 200)
+        self.assertEqual(response.fromcache, False)
+        (response, content) = self.http.request(uri, "GET")
+        self.assertEqual(response.status, 200)
+        self.assertEqual(response.fromcache, True)
+        (response, content) = self.http.request(uri, "PATCH", body="foo")
+        self.assertEqual(response.status, 200)
+        (response, content) = self.http.request(uri, "PATCH", body="foo")
+        self.assertEqual(response.status, 412)
+
+
     def testUpdateUsesCachedETagAndOCMethod(self):
         # Test that we natively support http://www.w3.org/1999/04/Editing/ 
         uri = urlparse.urljoin(base, "conditional-updates/test.cgi")
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index 0e7184f..9c48d8f 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -843,8 +843,8 @@
 
         # Which HTTP methods do we apply optimistic concurrency to, i.e.
         # which methods get an "if-match:" etag header added to them.
-        self.optimistic_concurrency_methods = ["PUT"]
-        
+        self.optimistic_concurrency_methods = ["PUT", "PATCH"]
+
         # If 'follow_redirects' is True, and this is set to True then
         # all redirecs are followed, including unsafe ones.
         self.follow_all_redirects = False
diff --git a/python3/httplib2test.py b/python3/httplib2test.py
index 7860143..61a297a 100755
--- a/python3/httplib2test.py
+++ b/python3/httplib2test.py
@@ -886,6 +886,22 @@
         (response, content) = self.http.request(uri, "PUT", body="foo")

         self.assertEqual(response.status, 412)

 

+

+    def testUpdatePatchUsesCachedETag(self):

+        # Test that we natively support http://www.w3.org/1999/04/Editing/ 

+        uri = urllib.parse.urljoin(base, "conditional-updates/test.cgi")

+

+        (response, content) = self.http.request(uri, "GET")

+        self.assertEqual(response.status, 200)

+        self.assertEqual(response.fromcache, False)

+        (response, content) = self.http.request(uri, "GET")

+        self.assertEqual(response.status, 200)

+        self.assertEqual(response.fromcache, True)

+        (response, content) = self.http.request(uri, "PATCH", body="foo")

+        self.assertEqual(response.status, 200)

+        (response, content) = self.http.request(uri, "PATCH", body="foo")

+        self.assertEqual(response.status, 412)

+

     def testUpdateUsesCachedETagAndOCMethod(self):

         # Test that we natively support http://www.w3.org/1999/04/Editing/ 

         uri = urllib.parse.urljoin(base, "conditional-updates/test.cgi")