diff --git a/splunklib/binding.py b/splunklib/binding.py index b0ed20e1b..db3e590c9 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -566,7 +566,7 @@ def connect(self): @_authentication @_log_duration - def delete(self, path_segment, owner=None, app=None, sharing=None, **query): + def delete(self, path_segment, owner=None, app=None, headers=None, sharing=None, **query): """Performs a DELETE operation at the REST path segment with the given namespace and query. @@ -589,6 +589,8 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query): :type owner: ``string`` :param app: The app context of the namespace (optional). :type app: ``string`` + :param headers: List of extra HTTP headers to send (optional). + :type headers: ``list`` of 2-tuples. :param sharing: The sharing mode of the namespace (optional). :type sharing: ``string`` :param query: All other keyword arguments, which are used as query @@ -616,10 +618,15 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query): c.logout() c.delete('apps/local') # raises AuthenticationError """ + + if headers is None: + headers = [] + path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing) logging.debug("DELETE request to %s (body: %s)", path, repr(query)) - response = self.http.delete(path, self._auth_headers, **query) + all_headers = headers + self.additional_headers + self._auth_headers + response = self.http.delete(path, all_headers, **query) return response @_authentication