aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDino Macri <36100525+dinomacri@users.noreply.github.com>2018-07-20 19:25:32 +0930
committerLukas Fleischer <lfleischer@calcurse.org>2018-07-22 10:58:33 +0200
commit61dc7ab53843567636eaac3874eff299ec8c10bd (patch)
tree5767bb5d9c1f2ec86ca41e61c51a011e749d98cc
parent163730cabfa16bd044d3f68a0013f8adee551bbe (diff)
downloadcalcurse-61dc7ab53843567636eaac3874eff299ec8c10bd.tar.gz
calcurse-61dc7ab53843567636eaac3874eff299ec8c10bd.zip
calcurse-caldav: add HTTP support
Introduce support for HTTP connections. Use "HTTPS" in the config file to enable/disable (default is enabled). The option modifies the prefix of the host name to "http://" when disabled, rather than always using "https://" with no option to change. httplib2 automatically handles URLs beginning with either http or https. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rwxr-xr-xcontrib/caldav/calcurse-caldav.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py
index 33971e0..39409d6 100755
--- a/contrib/caldav/calcurse-caldav.py
+++ b/contrib/caldav/calcurse-caldav.py
@@ -533,16 +533,17 @@ try:
except FileNotFoundError as e:
die('Configuration file not found: {}'.format(configfn))
-hostname = config.get('General', 'HostName')
-path = '/' + config.get('General', 'Path').strip('/') + '/'
-hostname_uri = 'https://' + hostname
-absolute_uri = hostname_uri + path
-
if config.has_option('General', 'InsecureSSL'):
insecure_ssl = config.getboolean('General', 'InsecureSSL')
else:
insecure_ssl = False
+# Read config for "HTTPS" option (default=True)
+if config.has_option('General', 'HTTPS'):
+ https = config.getboolean('General', 'HTTPS')
+else:
+ https = True
+
if config.has_option('General', 'Binary'):
calcurse = config.get('General', 'Binary')
else:
@@ -607,6 +608,17 @@ if config.has_option('OAuth2', 'RedirectURI'):
else:
redirect_uri = 'http://127.0.0.1'
+# Change URl prefix according to HTTP/HTTPS
+if https:
+ urlprefix = "https://"
+else:
+ urlprefix = "http://"
+
+hostname = config.get('General', 'HostName')
+path = '/' + config.get('General', 'Path').strip('/') + '/'
+hostname_uri = urlprefix + hostname
+absolute_uri = hostname_uri + path
+
# Show disclaimer when performing a dry run.
if dry_run:
warn(('Dry run; nothing is imported/exported. Add "DryRun = No" to the '
@@ -633,7 +645,7 @@ if os.path.exists(lockfn):
open(lockfn, 'w')
try:
- # Connect to the server via HTTPs.
+ # Connect to the server.
if verbose:
print('Connecting to ' + hostname + '...')
conn = httplib2.Http()