From 61dc7ab53843567636eaac3874eff299ec8c10bd Mon Sep 17 00:00:00 2001 From: Dino Macri <36100525+dinomacri@users.noreply.github.com> Date: Fri, 20 Jul 2018 19:25:32 +0930 Subject: 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 --- contrib/caldav/calcurse-caldav.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'contrib/caldav') 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() -- cgit v1.2.3-70-g09d2