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")