Changeset 1762
- Timestamp:
- 10/21/07 20:29:33
- Files:
-
- trunk/cherrypy/lib/encoding.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/encoding.py
r1722 r1762 51 51 # Encoding 52 52 53 def encode(encoding=None, errors='strict' ):53 def encode(encoding=None, errors='strict', text_only=True, add_charset=True): 54 54 # Guard against running twice 55 55 if getattr(cherrypy.request, "_encoding_attempted", False): … … 60 60 if ct: 61 61 ct = ct[0] 62 if ct.value.lower().startswith("text/"):62 if (not text_only) or ct.value.lower().startswith("text/"): 63 63 # Set "charset=..." param on response Content-Type header 64 64 ct.params['charset'] = find_acceptable_charset(encoding, errors=errors) 65 cherrypy.response.headers["Content-Type"] = str(ct) 65 if add_charset: 66 cherrypy.response.headers["Content-Type"] = str(ct) 66 67 67 68 def encode_stream(encoding, errors='strict'):

