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:
parent
163730cabf
commit
61dc7ab538
@ -533,16 +533,17 @@ try:
|
|||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
die('Configuration file not found: {}'.format(configfn))
|
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'):
|
if config.has_option('General', 'InsecureSSL'):
|
||||||
insecure_ssl = config.getboolean('General', 'InsecureSSL')
|
insecure_ssl = config.getboolean('General', 'InsecureSSL')
|
||||||
else:
|
else:
|
||||||
insecure_ssl = False
|
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'):
|
if config.has_option('General', 'Binary'):
|
||||||
calcurse = config.get('General', 'Binary')
|
calcurse = config.get('General', 'Binary')
|
||||||
else:
|
else:
|
||||||
@ -607,6 +608,17 @@ if config.has_option('OAuth2', 'RedirectURI'):
|
|||||||
else:
|
else:
|
||||||
redirect_uri = 'http://127.0.0.1'
|
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.
|
# Show disclaimer when performing a dry run.
|
||||||
if dry_run:
|
if dry_run:
|
||||||
warn(('Dry run; nothing is imported/exported. Add "DryRun = No" to the '
|
warn(('Dry run; nothing is imported/exported. Add "DryRun = No" to the '
|
||||||
@ -633,7 +645,7 @@ if os.path.exists(lockfn):
|
|||||||
open(lockfn, 'w')
|
open(lockfn, 'w')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Connect to the server via HTTPs.
|
# Connect to the server.
|
||||||
if verbose:
|
if verbose:
|
||||||
print('Connecting to ' + hostname + '...')
|
print('Connecting to ' + hostname + '...')
|
||||||
conn = httplib2.Http()
|
conn = httplib2.Http()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user