chibisov / drf-extensions

DRF-extensions is a collection of custom extensions for Django REST Framework
http://chibisov.github.io/drf-extensions/docs
MIT License
1.47k stars 208 forks source link

CacheResponse assumes a pickle serializer is used, breaking on any other serializers #267

Closed gcbirzan closed 5 years ago

gcbirzan commented 5 years ago

As per the WSGI spec, headers must be a list of tuples. If you use a serialization format that doesn't support tuples (i.e. any that's not pickle), headers will end up being a list of lists. This then breaks if you try to use % to format the values.

https://github.com/chibisov/drf-extensions/blob/437926b91989e402ef0824c15d54f09d989d2f1a/rest_framework_extensions/cache/decorators.py#L99

This is the bit of code that causes this. A solution would be to iterate through the headers and use __setitem__ as that will take care of putting tuples.

auvipy commented 5 years ago

PR is welcome :)