Fixed pistons content-type issue.

Pistons utils.Mimer.loader_for_type now get wrapped to remove
everything behind a ; (including the ;).
master
seba 13 years ago
parent 5a25b97c59
commit 2d11431e63

@ -85,3 +85,14 @@ def requirePlugin(apiFunc):
return ret
return wrapper
def fix_mime(mime_func):
""" Fix mimetype by truncating everything behind a ';'.
This is used to fix pistons ``piston.utils.Mimer.loader_for_type``."""
@wraps(mime_func)
def wrapper(self, ctype):
if ctype and ctype.find(";") >= 0:
ctype = ctype.split(";")[0]
return mime_func(self, ctype)
return wrapper

@ -3,6 +3,11 @@ from piston.resource import Resource
from piston.authentication import HttpBasicAuthentication
from api2.authentication import DjangoAuthentication, MultiAuthentication
from api2.handlers import *
from api2.decorators import fix_mime
import piston.utils
# piston does not understand mimetypes with charsets, HACK: fix loader_for_type
piston.utils.Mimer.loader_for_type = fix_mime(piston.utils.Mimer.loader_for_type)
class CsrfExemptResource( Resource ):
""" Except a :class:`Resource` from djangos CSRF-Framework.

Loading…
Cancel
Save