(data, headers)
| 11366 | } |
| 11367 | |
| 11368 | function defaultHttpResponseTransform(data, headers) { |
| 11369 | if (isString(data)) { |
| 11370 | // Strip json vulnerability protection prefix and trim whitespace |
| 11371 | var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim(); |
| 11372 | |
| 11373 | if (tempData) { |
| 11374 | var contentType = headers('Content-Type'); |
| 11375 | var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0); |
| 11376 | |
| 11377 | if (hasJsonContentType || isJsonLike(tempData)) { |
| 11378 | try { |
| 11379 | data = fromJson(tempData); |
| 11380 | } catch (e) { |
| 11381 | if (!hasJsonContentType) { |
| 11382 | return data; |
| 11383 | } |
| 11384 | throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' + |
| 11385 | 'Parse error: "{1}"', data, e); |
| 11386 | } |
| 11387 | } |
| 11388 | } |
| 11389 | } |
| 11390 | |
| 11391 | return data; |
| 11392 | } |
| 11393 | |
| 11394 | function isJsonLike(str) { |
| 11395 | var jsonStart = str.match(JSON_START); |
nothing calls this directly
no test coverage detected