Issue 69: Adding Headers Support for JSON and XML

pull/70/head
Kaustubh Phatak 6 years ago
parent ef76996826
commit 753e36feab
No known key found for this signature in database
GPG Key ID: B79B46BF74CB18E4

3
.gitignore vendored

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

@ -162,6 +162,7 @@ class NotifyBase(object):
self.user = kwargs.get('user') self.user = kwargs.get('user')
self.password = kwargs.get('password') self.password = kwargs.get('password')
self.headers = kwargs.get('headers')
if 'format' in kwargs: if 'format' in kwargs:
# Store the specified format if specified # Store the specified format if specified
@ -424,4 +425,5 @@ class NotifyBase(object):
if 'user' in results['qsd']: if 'user' in results['qsd']:
results['user'] = results['qsd']['user'] results['user'] = results['qsd']['user']
results['headers'] = {k[1:]: v for k, v in results['qsd'].items() if re.match(r'^-.', k)}
return results return results

@ -91,6 +91,9 @@ class NotifyJSON(NotifyBase):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
if self.headers:
headers.update(self.headers)
auth = None auth = None
if self.user: if self.user:
auth = (self.user, self.password) auth = (self.user, self.password)

@ -96,6 +96,9 @@ class NotifyXML(NotifyBase):
'Content-Type': 'application/xml' 'Content-Type': 'application/xml'
} }
if self.headers:
headers.update(self.headers)
re_map = { re_map = {
'{MESSAGE_TYPE}': NotifyBase.quote(notify_type), '{MESSAGE_TYPE}': NotifyBase.quote(notify_type),
'{SUBJECT}': NotifyBase.quote(title), '{SUBJECT}': NotifyBase.quote(title),

Loading…
Cancel
Save