Allow additional HTTP headers in configuration file

Best ratio coolness/sloc ever!
This commit is contained in:
Guillaume Ayoub 2013-05-13 18:15:08 +02:00
parent 040d3b87a8
commit fab7796ca0
2 changed files with 9 additions and 0 deletions

5
config
View File

@ -126,3 +126,8 @@ config = /etc/radicale/logging
debug = False debug = False
# Store all environment variables (including those set in the shell) # Store all environment variables (including those set in the shell)
full_environment = False full_environment = False
# Additional HTTP headers
#[headers]
#Access-Control-Allow-Origin = *

View File

@ -313,6 +313,10 @@ class Application(object):
"Response content:\n%s" % self.decode(answer, environ)) "Response content:\n%s" % self.decode(answer, environ))
headers["Content-Length"] = str(len(answer)) headers["Content-Length"] = str(len(answer))
if config.has_section("headers"):
for key in config.options("headers"):
headers[key] = config.get("headers", key)
# Start response # Start response
status = "%i %s" % (status, client.responses.get(status, "Unknown")) status = "%i %s" % (status, client.responses.get(status, "Unknown"))
log.LOGGER.debug("Answer status: %s" % status) log.LOGGER.debug("Answer status: %s" % status)