diff options
author | cce <devnull@localhost> | 2005-12-29 16:11:41 +0000 |
---|---|---|
committer | cce <devnull@localhost> | 2005-12-29 16:11:41 +0000 |
commit | acff0f7c14cac2cc12820ec15361b87ed8d9b396 (patch) | |
tree | d4bcbb829f443541d665fa3992d8d3f44018b2ee /paste/httpheaders.py | |
parent | 4a1eb6c7ddbcb616193959fb155c6ac613b12baf (diff) | |
download | paste-acff0f7c14cac2cc12820ec15361b87ed8d9b396.tar.gz |
- make ContentType and ContentLength pickup CGI environment variable if
the corresponding header is not found (hopefully this redundance can
be removed from WSGI)
Diffstat (limited to 'paste/httpheaders.py')
-rw-r--r-- | paste/httpheaders.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/paste/httpheaders.py b/paste/httpheaders.py index 9b4ad9d..3623704 100644 --- a/paste/httpheaders.py +++ b/paste/httpheaders.py @@ -629,9 +629,26 @@ class CacheControl(MultiValueHeader): CacheControl = CacheControl('Cache-Control','general') -class ContentType(SingleValueHeader): +class SingleValueCGIHeader(SingleValueHeader): + """ + This is a base class for Content-Type and Content-Length headers, + which besides their HTTP_ entries may also have a CGI version. + The logic is to only use the CGI version when the HTTP_ version is + missing. Hopefully this can be removed. + """ + def __call__(self, *args, **kwargs): + if args and dict == type(args[0]): + if not args[0].get(self._environ_name): + cgi_name = self._environ_name[5:] + return self.format(args[0].get(cgi_name)) + return SingleValueHeader.__call__(self, *args, **kwargs) + +class ContentType(SingleValueCGIHeader): """ Content-Type, RFC 2616 section 14.17 + + If the 'Content-Type' does not appear in the ``environ`` the + corresponding CGI variable is searched. """ version = '1.0' @@ -656,6 +673,12 @@ class ContentType(SingleValueHeader): return (result,) ContentType = ContentType('Content-Type','entity') +class ContentLength(SingleValueCGIHeader): + """ + Content-Length, RFC 2616 section 14.13 + """ + version = "1.0" +ContentLength = ContentLength('Content-Length','entity') class ContentDisposition(SingleValueHeader): """ @@ -755,7 +778,7 @@ for (name, category, version, style, comment) in \ ,("Content-Encoding" ,'entity' ,'1.0','multi-value','RFC 2616 $14.11') #,("Content-Disposition",'entity' ,'1.1','multi-value','RFC 2616 $15.5' ) ,("Content-Language" ,'entity' ,'1.1','multi-value','RFC 2616 $14.12') -,("Content-Length" ,'entity' ,'1.0','singular' ,'RFC 2616 $14.13') +#,("Content-Length" ,'entity' ,'1.0','singular' ,'RFC 2616 $14.13') ,("Content-Location" ,'entity' ,'1.1','singular' ,'RFC 2616 $14.14') ,("Content-MD5" ,'entity' ,'1.1','singular' ,'RFC 2616 $14.15') ,("Content-Range" ,'entity' ,'1.1','singular' ,'RFC 2616 $14.16') |