You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Stream is readable, you can pipe or read the error body
234
+
}
235
+
});
236
+
237
+
awaitstreamPipeline(stream, process.stdout);
238
+
```
239
+
218
240
**Example: Filter headers when proxying to ServerResponse**
219
241
220
242
```js
@@ -267,6 +289,7 @@ When this event is emitted, you should reset the stream you were writing to and
267
289
> -[`HTTPError`s](./8-errors.md#httperror) cannot be retried if [`options.throwHttpErrors`](./2-options.md#throwhttperrors) is `false`.
268
290
> This is because stream data is saved to `error.response.body` and streams can be read only once.
269
291
> - For the Promise API, there is no such limitation.
292
+
> - If you need to read HTTP error response bodies without retry, see [Reading HTTP error response bodies](#example-reading-http-error-response-bodies).
270
293
271
294
#### `retryCount`
272
295
@@ -402,6 +425,7 @@ Whether the response was successful
402
425
> - When [following redirects](2-options.md#followredirect), a request is successful **only** when the status code of the final request is `2xx`.
403
426
> - `304` responses are always considered successful.
404
427
> - Got throws automatically when `response.ok` is `false` and `throwHttpErrors` is `true`.
428
+
> - **To read HTTP error response bodies with streams**, set `throwHttpErrors:false` and check `response.ok` in the `response` event handler. [See example above](#example-reading-http-error-response-bodies).
0 commit comments