Radicale icon indicating copy to clipboard operation
Radicale copied to clipboard

Headers in config file issue : AssertionError: Header names must be strings

Open ralf35 opened this issue 7 years ago • 2 comments

Hello, i am using Radicale ubuntu package 1.1.1.1 for some years with caldavzap as one of the client I had to restart my server yesterday and radicale stop working.

Headers in config file are an issue for some reasons :

Additional HTTP headers

[headers] Access-Control-Allow-Origin = * Access-Control-Allow-Methods = GET, POST, OPTIONS, PROPFIND, PROPPATCH, REPORT, PUT, MOVE, DELETE, LOCK, UNLOCK Access-Control-Allow-Headers = User-Agent, Authorization, Content-type, Depth, If-match, If-None-Match, Lock-Token, Timeout, Destination, Overwrite, X-client, X-Requested-With, Prefer Access-Control-Expose-Headers = Etag

Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.7/dist-packages/radicale/init.py", line 360, in call start_response(status, list(headers.items())) File "/usr/lib/python2.7/wsgiref/handlers.py", line 179, in start_response assert type(name) is StringType,"Header names must be strings" AssertionError: Header names must be strings Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.7/dist-packages/radicale/init.py", line 360, in call start_response(status, list(headers.items())) File "/usr/lib/python2.7/wsgiref/handlers.py", line 179, in start_response assert type(name) is StringType,"Header names must be strings" AssertionError: Header names must be strings

Radicale server response is http 500

It works well if I comment all the headers lines. But obviously Caldavzap doesnt :(

I guess it is a python change that might cause the issue

ralf35 avatar Feb 11 '18 21:02 ralf35

I work around this : I migrate to radicale2. I was unable to find the issue

ralf35 avatar Mar 05 '18 16:03 ralf35

I'm using 1.1.6 and encountered the same error after I restarted my server today. Yesterday I installed some python packages into the system. I can't migrate to 2 because my address books can't be processed there.

P.S. I have patched the file myself - it is unicode-related issue:

--- __init__.py.distrib 2017-07-26 08:24:08.000000000 +0800
+++ __init__.py 2020-04-27 09:47:55.602254392 +0800
@@ -352,7 +352,12 @@
 
         if config.has_section("headers"):
             for key in config.options("headers"):
-                headers[key] = config.get("headers", key)
+                if isinstance(key, unicode):
+                    key = key.encode("utf-8")
+                value = config.get("headers", key)
+                if isinstance(value, unicode):
+                    value = value.encode("utf-8")
+                headers[key] = value
 
         # Start response
         status = "%i %s" % (status, client.responses.get(status, "Unknown"))

miklcct avatar Apr 27 '20 01:04 miklcct

related to old version, closing now, if reproducable with current version of radicale, please reopen.

pbiering avatar Oct 22 '24 04:10 pbiering