()
| 190 | if (url) { |
| 191 | if (type || Object.keys(newHeaders).length > 0) { |
| 192 | const getRes = async () => { |
| 193 | $.log('需下载', url) |
| 194 | const res = await $.http.get({ |
| 195 | url, |
| 196 | headers: reqHeaders.headers, |
| 197 | // headers: $.lodash_get($request, 'headers'), |
| 198 | }) |
| 199 | // $.log('ℹ️ res', $.toStr(res)) |
| 200 | const status = $.lodash_get(res, 'status') || $.lodash_get(res, 'statusCode') || 200 |
| 201 | $.log('ℹ️ res status', status) |
| 202 | const headers = $.lodash_get(res, 'headers') |
| 203 | // $.log('ℹ️ res headers', $.toStr(headers)) |
| 204 | |
| 205 | // if (!type) { |
| 206 | const type = $.lodash_get(headers, 'content-type') || $.lodash_get(headers, 'Content-Type') |
| 207 | |
| 208 | // $.log('ℹ️ res type', type) |
| 209 | // } |
| 210 | |
| 211 | let body = $.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody') |
| 212 | |
| 213 | // $.log('ℹ️ res body', body) |
| 214 | return { body, type, status, headers, shouldCache: typeof body === 'string' } |
| 215 | } |
| 216 | |
| 217 | // let res |
| 218 | // if (noCache) { |
no test coverage detected