Better handling of non-JSON responses.
(Compiled version of previous source commit.)