diff options
author | cce <devnull@localhost> | 2005-12-23 01:23:52 +0000 |
---|---|---|
committer | cce <devnull@localhost> | 2005-12-23 01:23:52 +0000 |
commit | 5ffb1dc28cfeeb5e580168c014fee9f239da3273 (patch) | |
tree | 09a7a95ed3eca0b35cd1da38f64dbf71740efc9c /paste/response.py | |
parent | 9b44a755fa49a5e4bee3a6bbc1e09edb9a1609af (diff) | |
download | paste-5ffb1dc28cfeeb5e580168c014fee9f239da3273.tar.gz |
- made __call__ for an HTTPException be the same as wsgi_application
- added if-modified-since logic to fileapp.py
- added helper to mark file/data as cached in fileapp.py
- added starter regression test for fileapp.py
note: if-modified-since is still slighly broken due to timezone issues
(it isn't consistenly keeping gmtime and localtime)
Diffstat (limited to 'paste/response.py')
-rw-r--r-- | paste/response.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/paste/response.py b/paste/response.py index 23d91cc..4362d67 100644 --- a/paste/response.py +++ b/paste/response.py @@ -107,6 +107,30 @@ def remove_header(headers, name): i += 1 return result +def replace_header(headers, name, value): + """ + Updates the headers replacing the first occurance of the given name + with the value provided; asserting that no further occurances + happen. Note that this is _not_ the same as remove_header and then + append, as two distinct operations (del followed by an append) are + not atomic in a threaded environment. Returns the previous header + value for the provided name, if any. Clearly one should not use + this function with ``set-cookie`` or other names that may have more + than one occurance in the headers. + """ + name = name.lower() + i = 0 + result = None + while i < len(headers): + if headers[i][0].lower() == name: + assert not result, "two values for the header '%s' found" % name + result = headers[i][1] + headers[i] = (name,value) + i += 1 + if not result: + headers.append((name,value)) + return result + ############################################################ ## Deprecated methods ############################################################ |