(data, headers)
| 11439 | } |
| 11440 | |
| 11441 | function defaultHttpResponseTransform(data, headers) { |
| 11442 | if (isString(data)) { |
| 11443 | // Strip json vulnerability protection prefix and trim whitespace |
| 11444 | var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim(); |
| 11445 | |
| 11446 | if (tempData) { |
| 11447 | var contentType = headers('Content-Type'); |
| 11448 | var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0); |
| 11449 | |
| 11450 | if (hasJsonContentType || isJsonLike(tempData)) { |
| 11451 | try { |
| 11452 | data = fromJson(tempData); |
| 11453 | } catch (e) { |
| 11454 | if (!hasJsonContentType) { |
| 11455 | return data; |
| 11456 | } |
| 11457 | throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' + |
| 11458 | 'Parse error: "{1}"', data, e); |
| 11459 | } |
| 11460 | } |
| 11461 | } |
| 11462 | } |
| 11463 | |
| 11464 | return data; |
| 11465 | } |
| 11466 | |
| 11467 | function isJsonLike(str) { |
| 11468 | var jsonStart = str.match(JSON_START); |
nothing calls this directly
no test coverage detected