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>
This commit is contained in:
Dino Macri 2018-07-20 19:25:32 +09:30 committed by Lukas Fleischer
parent 163730cabf
commit 61dc7ab538

View File

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