calcurse-caldav: Support custom HTTP headers
Add support for specifying additional HTTP headers, such as the User-Agent, in the configuration file. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
475c341686
commit
849459c63f
@ -83,7 +83,8 @@ def get_auth_headers():
|
|||||||
return headers
|
return headers
|
||||||
|
|
||||||
def remote_query(cmd, path, additional_headers, body):
|
def remote_query(cmd, path, additional_headers, body):
|
||||||
headers = get_auth_headers()
|
headers = custom_headers.copy()
|
||||||
|
headers.update(get_auth_headers())
|
||||||
if cmd == 'PUT':
|
if cmd == 'PUT':
|
||||||
headers['Content-Type'] = 'text/calendar; charset=utf-8'
|
headers['Content-Type'] = 'text/calendar; charset=utf-8'
|
||||||
else:
|
else:
|
||||||
@ -380,6 +381,11 @@ if config.has_option('Auth', 'Password'):
|
|||||||
else:
|
else:
|
||||||
password = None
|
password = None
|
||||||
|
|
||||||
|
if config.has_section('CustomHeaders'):
|
||||||
|
custom_headers = dict(config.items('CustomHeaders'))
|
||||||
|
else:
|
||||||
|
custom_headers = {}
|
||||||
|
|
||||||
# Show disclaimer when performing a dry run.
|
# Show disclaimer when performing a dry run.
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print('Dry run. Nothing is actually imported/exported.')
|
print('Dry run. Nothing is actually imported/exported.')
|
||||||
|
@ -29,3 +29,7 @@ Verbose = Yes
|
|||||||
#[Auth]
|
#[Auth]
|
||||||
#Username = user
|
#Username = user
|
||||||
#Password = pass
|
#Password = pass
|
||||||
|
|
||||||
|
# Optionally specify additional HTTP headers here.
|
||||||
|
#[CustomHeaders]
|
||||||
|
#User-Agent = Mac_OS_X/10.9.2 (13C64) CalendarAgent/176
|
||||||
|
Loading…
x
Reference in New Issue
Block a user