[Calypso] [PATCH 01/15] add custom headers via config file

Guido Günther agx at sigxcpu.org
Sat Apr 9 15:46:52 PDT 2016


On Sat, Apr 09, 2016 at 07:15:12PM +0000, Jelmer Vernooij wrote:
> From: chrysn <chrysn at fsfe.org>
> 
> this is required when using calypso with a web application on a
> different server

LGTM and passes our minimal caldav-tester suite.
 -- Guido

> ---
>  calypso/__init__.py |  3 +++
>  calypso/config.py   |  6 +++++-
>  config              | 11 +++++++++++
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/calypso/__init__.py b/calypso/__init__.py
> index 18cb880..d50329b 100644
> --- a/calypso/__init__.py
> +++ b/calypso/__init__.py
> @@ -157,6 +157,9 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
>          self.send_response(response)
>          self.send_connection_header()
>          self.send_header("Content-Length", length)
> +        for header, value in config.items('headers'):
> +            self.send_header(header, value)
> +
>  
>      def handle_one_request(self):
>          """Handle a single HTTP request.
> diff --git a/calypso/config.py b/calypso/config.py
> index 59cbd85..0c3fee9 100644
> --- a/calypso/config.py
> +++ b/calypso/config.py
> @@ -60,7 +60,11 @@ INITIAL_CONFIG = {
>          "pam_service": "passwd",
>      },
>      "storage": {
> -        "folder": os.path.expanduser("~/.config/calypso/calendars")}}
> +        "folder": os.path.expanduser("~/.config/calypso/calendars")
> +    },
> +    "headers": {
> +    },
> +}
>  
>  # Create a ConfigParser and configure it
>  _CONFIG_PARSER = ConfigParser()
> diff --git a/config b/config
> index 1ef574c..7093716 100644
> --- a/config
> +++ b/config
> @@ -51,4 +51,15 @@ encryption = crypt
>  # created if not present
>  folder = ~/.config/calypso/calendars
>  
> +# The headers section allows verbatim addition of static headers to
> +# responses. The following exemplary headers are useful when the calendar
> +# should be accessed from users' web browsers using a web application hosted on
> +# a different server.
> +#
> +#[headers]
> +#Access-Control-Allow-Origin = *
> +#Access-Control-Allow-Credentials = *
> +#Access-Control-Allow-Methods = GET, POST, PUT, DELETE, PROPFIND, REPORT
> +#Access-Control-Allow-Headers = accept, authorization, content-type, depth, x-client, if-match
> +
>  # vim:ft=cfg
> -- 
> 2.8.0.rc3
> 
> _______________________________________________
> Calypso mailing list
> Calypso at keithp.com
> http://keithp.com/mailman/listinfo/calypso


More information about the Calypso mailing list