Issue 69: Adding Headers Support for JSON and XML

This commit is contained in:
Kaustubh Phatak 2019-02-15 13:25:38 -08:00
parent ef76996826
commit 753e36feab
No known key found for this signature in database
GPG Key ID: B79B46BF74CB18E4
4 changed files with 11 additions and 0 deletions

3
.gitignore vendored
View File

@ -61,3 +61,6 @@ target/
#Ipython Notebook
.ipynb_checkpoints
#PyCharm
.idea

View File

@ -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

View File

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

View File

@ -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),