Browse Source

Radicale Access-Control-Allow-Origin parameter optional

Bastien Sevajol (Algoo) 8 years ago
parent
commit
fad490f377
1 changed files with 12 additions and 5 deletions
  1. 12 5
      tracim/tracim/lib/daemons.py

+ 12 - 5
tracim/tracim/lib/daemons.py View File

1
 import threading
1
 import threading
2
+from configparser import DuplicateSectionError
2
 from wsgiref.simple_server import make_server
3
 from wsgiref.simple_server import make_server
3
 import signal
4
 import signal
4
 
5
 
189
         radicale_config.set('storage', 'custom_handler', tracim_storage)
190
         radicale_config.set('storage', 'custom_handler', tracim_storage)
190
         radicale_config.set('storage', 'filesystem_folder', fs_path)
191
         radicale_config.set('storage', 'filesystem_folder', fs_path)
191
 
192
 
192
-        radicale_config.set(
193
-            'header',
194
-            'Access-Control-Allow-Origin',
195
-            allow_origin,
196
-        )
193
+        if allow_origin:
194
+            try:
195
+                radicale_config.add_section('headers')
196
+            except DuplicateSectionError:
197
+                pass  # It is not a problem, we just want it exist
198
+
199
+            radicale_config.set(
200
+                'headers',
201
+                'Access-Control-Allow-Origin',
202
+                allow_origin,
203
+            )
197
 
204
 
198
     def _get_server(self):
205
     def _get_server(self):
199
         from tracim.config.app_cfg import CFG
206
         from tracim.config.app_cfg import CFG