From 9c0c2278cda56f6017740ab69a16b81eeb1b6061 Mon Sep 17 00:00:00 2001
From: Daniel Nowak <13685818+lowlyocean@users.noreply.github.com>
Date: Tue, 20 Sep 2022 14:26:31 -0400
Subject: [PATCH] Don't include optional header in request if blank
---
motioneye/static/js/main.js | 4 ++--
motioneye/templates/main.html | 8 ++++----
motioneye/webhook.py | 14 ++++++++------
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js
index d92a37f81..7d215ae83 100644
--- a/motioneye/static/js/main.js
+++ b/motioneye/static/js/main.js
@@ -662,9 +662,9 @@ function initUI() {
return true;
}, '');
- makeCustomValidator($('#webHookNotificationsUrlEntry, #webHookEndNotificationsUrlEntry, #webHookNotificationsAcceptHeader, #webHookEndNotificationsAcceptHeader, #webHookNotificationsUserAgent, #webHookEndNotificationsUserAgent'), function (value) {
+ makeCustomValidator($('#webHookNotificationsUrlEntry, #webHookEndNotificationsUrlEntry'), function (value) {
if (!value.match(webHookUrlValidRegExp)) {
- return "use of semicolon (;) or single quote (') is not allowed in web hook URL, Accept, or User-Agent headers";
+ return "use of semicolon (;) or single quote (') is not allowed in web hook URL";
}
return true;
diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html
index e33bf1020..6e8021433 100644
--- a/motioneye/templates/main.html
+++ b/motioneye/templates/main.html
@@ -1149,12 +1149,12 @@
? |
-
+
Accept Header |
|
? |
-
+
User-Agent Header |
|
? |
@@ -1204,12 +1204,12 @@
? |
-
+
Accept Header |
|
? |
-
+
User-Agent Header |
|
? |
diff --git a/motioneye/webhook.py b/motioneye/webhook.py
index 96f62d7b7..3e0d515e6 100644
--- a/motioneye/webhook.py
+++ b/motioneye/webhook.py
@@ -24,9 +24,9 @@
def parse_options(parser, args):
- parser.add_argument('method', help='the HTTP method to use')
- parser.add_argument('accept', help='the Accept header for the request')
parser.add_argument('useragent', help='the User Agent header for the request')
+ parser.add_argument('accept', help='the Accept header for the request')
+ parser.add_argument('method', help='the HTTP method to use')
parser.add_argument('url', help='the URL for the request')
return parser.parse_args(args)
@@ -42,17 +42,19 @@ def main(parser, args):
logging.debug('hello!')
logging.debug('method = %s' % options.method)
- logging.debug('accept = %s' % options.accept)
- logging.debug('useragent = %s' % options.useragent)
+ if 'accept' in options:
+ logging.debug('accept = %s' % options.accept)
+ if 'useragent' in options:
+ logging.debug('useragent = %s' % options.useragent)
logging.debug('url = %s' % options.url)
headers = {}
parts = urllib.parse.urlparse(options.url)
url = options.url
data = None
- if 'accept' in options:
+ if 'accept' in options and options.accept:
headers['Accept'] = options.accept
- if 'useragent' in options:
+ if 'useragent' in options and options.useragent:
headers['User-Agent'] = options.useragent
if options.method == 'POST':