| 10170 | } |
| 10171 | const parsedHeaders = responseHeaders === "raw" ? util.parseHeaders(rawHeaders) : headers; |
| 10172 | const contentType = parsedHeaders["content-type"]; |
| 10173 | const contentLength = parsedHeaders["content-length"]; |
| 10174 | const res = new Readable({ |
| 10175 | resume, |
| 10176 | abort, |
| 10177 | contentType, |
| 10178 | contentLength: this.method !== "HEAD" && contentLength ? Number(contentLength) : null, |
| 10179 | highWaterMark |
| 10180 | }); |
| 10181 | if (this.removeAbortListener) { |
| 10182 | res.on("close", this.removeAbortListener); |
| 10183 | } |
| 10184 | this.callback = null; |
| 10185 | this.res = res; |
| 10186 | if (callback !== null) { |
| 10187 | if (this.throwOnError && statusCode >= 400) { |
| 10188 | this.runInAsyncScope( |
| 10189 | getResolveErrorBodyCallback, |
| 10190 | null, |
| 10191 | { callback, body: res, contentType, statusCode, statusMessage, headers } |
| 10192 | ); |