bluestatedigital/bsdapi — pull request #1 by fidothe (2012-04-27 12:44:09+00:00)
Title: Makes the creation of unicode string from response body respect the Content-Type header

This is a work-around so that I can reliably call ApiResult.body.encode(charset) based on content-type, for using non-unicode strings with LXML (XML api responses specify charset in the declaration, and lxml refuses to play with already-unicoded XML strings which specify encoding again).

A less-hacky workaround would probably be to provide a body object which implemented to __str__ and __unicode__, lazily decoding the body bytestream if that was wanted.