I had a problem with Restful requests. The content-type response header was
text/plain when I sent a http://xxx.json request. Is it ok? I need
content-type response header as application/json. To do that I have
modified the glucon/contenttype.py with the following code:
*Original contenttype.py*
*
*
def contenttype(filename, default='text/plain'):
"""
Returns the Content-Type string matching extension of the given
filename.
"""
i = filename.rfind('.')
if i >= 0:
default = CONTENT_TYPE.get(filename[i:].lower(), default)
j = filename.rfind('.', 0, i)
if j >= 0:
default = CONTENT_TYPE.get(filename[j:].lower(), default)
if default.startswith('text/'):
default += '; charset=utf-8'
return default
*Modified contenttype.py*
*
*
def contenttype(filename, default='text/plain'):
"""
Returns the Content-Type string matching extension of the given
filename.
"""
i = filename.rfind('.')
if i >= 0:
default = CONTENT_TYPE.get(filename[i:].lower(), default)
j = filename.rfind('.', 0, i)
if j >= 0:
default = CONTENT_TYPE.get(filename[j:].lower(), default)
else:
default = CONTENT_TYPE.get('.' + filename.lower(), default)
if default.startswith('text/'):
default += '; charset=utf-8'
return default
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.