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,4 +1,5 @@
1 1
 import threading
2
+from configparser import DuplicateSectionError
2 3
 from wsgiref.simple_server import make_server
3 4
 import signal
4 5
 
@@ -189,11 +190,17 @@ class RadicaleDaemon(Daemon):
189 190
         radicale_config.set('storage', 'custom_handler', tracim_storage)
190 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 205
     def _get_server(self):
199 206
         from tracim.config.app_cfg import CFG