| 33 | * @returns {{ preview: string, response: string, data: Buffer }} |
| 34 | */ |
| 35 | const stringifyBody = async res => { |
| 36 | try { |
| 37 | // Some services provide a meaningful error message in the body of 403s like "token lacks the scopes necessary to perform this action" |
| 38 | const data = Buffer.from(await collect(res.body)) |
| 39 | const response = data.toString('utf8') |
| 40 | const preview = |
| 41 | response.length < 256 ? response : response.slice(0, 256) + '...' |
| 42 | return { preview, response, data } |
| 43 | } catch (e) { |
| 44 | return {} |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | export class GitRemoteHTTP { |
| 49 | /** |