(data, headers)
| 12073 | } |
| 12074 | |
| 12075 | function defaultHttpResponseTransform(data, headers) { |
| 12076 | if (isString(data)) { |
| 12077 | // Strip json vulnerability protection prefix and trim whitespace |
| 12078 | var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim(); |
| 12079 | |
| 12080 | if (tempData) { |
| 12081 | var contentType = headers('Content-Type'); |
| 12082 | var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0); |
| 12083 | |
| 12084 | if (hasJsonContentType || isJsonLike(tempData)) { |
| 12085 | try { |
| 12086 | data = fromJson(tempData); |
| 12087 | } catch (e) { |
| 12088 | if (!hasJsonContentType) { |
| 12089 | return data; |
| 12090 | } |
| 12091 | throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' + |
| 12092 | 'Parse error: "{1}"', data, e); |
| 12093 | } |
| 12094 | } |
| 12095 | } |
| 12096 | } |
| 12097 | |
| 12098 | return data; |
| 12099 | } |
| 12100 | |
| 12101 | function isJsonLike(str) { |
| 12102 | var jsonStart = str.match(JSON_START); |
nothing calls this directly
no test coverage detected