From 753e36feab203caff54a6d340da13a4e73693847 Mon Sep 17 00:00:00 2001 From: Kaustubh Phatak Date: Fri, 15 Feb 2019 13:25:38 -0800 Subject: [PATCH] Issue 69: Adding Headers Support for JSON and XML --- .gitignore | 3 +++ apprise/plugins/NotifyBase.py | 2 ++ apprise/plugins/NotifyJSON.py | 3 +++ apprise/plugins/NotifyXML.py | 3 +++ 4 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index b0986195..53a85462 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ target/ #Ipython Notebook .ipynb_checkpoints + +#PyCharm +.idea \ No newline at end of file diff --git a/apprise/plugins/NotifyBase.py b/apprise/plugins/NotifyBase.py index ab7114f0..3dc6cd0d 100644 --- a/apprise/plugins/NotifyBase.py +++ b/apprise/plugins/NotifyBase.py @@ -162,6 +162,7 @@ class NotifyBase(object): self.user = kwargs.get('user') self.password = kwargs.get('password') + self.headers = kwargs.get('headers') if 'format' in kwargs: # Store the specified format if specified @@ -424,4 +425,5 @@ class NotifyBase(object): if 'user' in results['qsd']: results['user'] = results['qsd']['user'] + results['headers'] = {k[1:]: v for k, v in results['qsd'].items() if re.match(r'^-.', k)} return results diff --git a/apprise/plugins/NotifyJSON.py b/apprise/plugins/NotifyJSON.py index 2501ee0a..ba160e92 100644 --- a/apprise/plugins/NotifyJSON.py +++ b/apprise/plugins/NotifyJSON.py @@ -91,6 +91,9 @@ class NotifyJSON(NotifyBase): 'Content-Type': 'application/json' } + if self.headers: + headers.update(self.headers) + auth = None if self.user: auth = (self.user, self.password) diff --git a/apprise/plugins/NotifyXML.py b/apprise/plugins/NotifyXML.py index 24940133..9b2f36b2 100644 --- a/apprise/plugins/NotifyXML.py +++ b/apprise/plugins/NotifyXML.py @@ -96,6 +96,9 @@ class NotifyXML(NotifyBase): 'Content-Type': 'application/xml' } + if self.headers: + headers.update(self.headers) + re_map = { '{MESSAGE_TYPE}': NotifyBase.quote(notify_type), '{SUBJECT}': NotifyBase.quote(title),