From 3556c50f07f4e161478cd4441e3b83b78d4d8007 Mon Sep 17 00:00:00 2001 From: Alexander Shorin Date: Sat, 22 Mar 2014 09:23:15 +0400 Subject: [PATCH] Support requests with HEAD method --- cloudant/resource.py | 7 +++++++ test/__init__.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/cloudant/resource.py b/cloudant/resource.py index 14b85d8..0729570 100644 --- a/cloudant/resource.py +++ b/cloudant/resource.py @@ -121,6 +121,13 @@ def logout(self, **kwargs): """De-authenticate the connection's cookie.""" return self.delete(self._reset_path('_session'), **kwargs) + def head(self, path='', **kwargs): + """ + Make a HEAD request against the object's URI joined + with `path`. `kwargs` are passed directly to Requests. + """ + return self._make_request('head', path, **kwargs) + def get(self, path='', **kwargs): """ Make a GET request against the object's URI joined diff --git a/test/__init__.py b/test/__init__.py index 0480af1..ff3afe9 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -144,6 +144,9 @@ def setUp(self): response = self.db.put() response.raise_for_status() + def testHead(self): + assert self.db.head().status_code == 200 + def testGet(self): assert self.db.get().status_code == 200