diff options
author | ianb <devnull@localhost> | 2007-03-06 01:21:21 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-03-06 01:21:21 +0000 |
commit | e33993bb26bb5e2f5bcc8b50a0b6067a2572d722 (patch) | |
tree | 0a932e98056aa4737ebffa812b224cea457786df /paste/fileapp.py | |
parent | f1f3cc7cd9ca003c4920825b8ad2521a43c02f4c (diff) | |
download | paste-e33993bb26bb5e2f5bcc8b50a0b6067a2572d722.tar.gz |
Make allowed headers settable in paste.fileapp.DataApp
Diffstat (limited to 'paste/fileapp.py')
-rw-r--r-- | paste/fileapp.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/paste/fileapp.py b/paste/fileapp.py index a2c1413..e9ba553 100644 --- a/paste/fileapp.py +++ b/paste/fileapp.py @@ -53,12 +53,18 @@ class DataApp(object): like changing ``Last-Modified`` and ``Content-Length`` headers. """ - def __init__(self, content, headers=None, **kwargs): + + allowed_methods = ('GET', 'HEAD') + + def __init__(self, content, headers=None, allowed_methods=None, + **kwargs): assert isinstance(headers, (type(None), list)) self.expires = None self.content = None self.content_length = None self.last_modified = 0 + if allowed_methods is not None: + self.allowed_methods = allowed_methods self.headers = headers or [] for (k, v) in kwargs.items(): header = get_header(k) @@ -90,10 +96,10 @@ class DataApp(object): def __call__(self, environ, start_response): method = environ['REQUEST_METHOD'].upper() - if method not in ('GET', 'HEAD'): + if method not in self.allowed_methods: exc = HTTPMethodNotAllowed( 'You cannot %s a file' % method, - headers=[('Allow', 'GET, HEAD')]) + headers=[('Allow', ','.join(self.allowed_methods))]) return exc(environ, start_response) return self.get(environ, start_response) |