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
Fix import style to workaround node < 10 and webpack issues. (node-fetch#544)
* fix import rule for stream PassThrough
* avoid named export for compatibility below node 10
* compress flag should not overwrite accept encoding header
* doc update
* 2.2.1
Copy file name to clipboardExpand all lines: LIMITS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,5 +26,7 @@ Known differences
26
26
27
27
- If you are using `res.clone()` and writing an isomorphic app, note that stream on Node.js have a smaller internal buffer size (16Kb, aka `highWaterMark`) from client-side browsers (>1Mb, not consistent across browsers).
28
28
29
+
- Because node.js stream doesn't expose a [*disturbed*](https://fetch.spec.whatwg.org/#concept-readablestream-disturbed) property like Stream spec, using a consumed stream for `new Response(body)` will not set `bodyUsed` flag correctly.
[TODO]: #(Somewhere i think we also should mention arrayBuffer also if you want to be cross-fetch compatible.)
187
-
188
186
#### Buffer
189
187
If you prefer to cache binary data in full, use buffer(). (NOTE: buffer() is a `node-fetch` only API)
190
188
@@ -265,8 +263,6 @@ Perform an HTTP(S) fetch.
265
263
266
264
`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected promise.
267
265
268
-
[TODO]: #(It might be a good idea to reformat the options section into a table layout, like the headers section, instead of current code block.)
269
-
270
266
<aid="fetch-options"></a>
271
267
### Options
272
268
@@ -285,23 +281,22 @@ The default values are shown after each option key.
285
281
timeout:0, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
286
282
compress:true, // support gzip/deflate content encoding. false to disable
287
283
size:0, // maximum response body size in bytes. 0 to disable
288
-
agent:null// http(s).Agent instance, allows custom proxy, certificate etc.
284
+
agent:null// http(s).Agent instance, allows custom proxy, certificate, dns lookup etc.
289
285
}
290
286
```
291
287
292
288
##### Default Headers
293
289
294
290
If no values are set, the following request headers will be sent automatically:
295
291
296
-
[TODO]: #("we always said content-length will be "automatically calculated, if possible" in the default header section, but we never explain what's the condition for it to be calculated, and that chunked transfer-encoding will be used when they are not calculated or supplied." - "Maybe also add Transfer-Encoding: chunked? That header is added by Node.js automatically if the input is a stream, I believe.")
@@ -451,8 +446,6 @@ Consume the body and return a promise that will resolve to one of these formats.
451
446
452
447
Consume the body and return a promise that will resolve to a Buffer.
453
448
454
-
[TODO]: #(textConverted API should mention an optional dependency on encoding, which users need to install by themselves, and this is done purely for backward compatibility with 1.x release.)
455
-
456
449
#### body.textConverted()
457
450
458
451
<small>*(node-fetch extension)*</small>
@@ -461,6 +454,8 @@ Consume the body and return a promise that will resolve to a Buffer.
461
454
462
455
Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8, if possible.
463
456
457
+
(This API requires an optional dependency on npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.)
0 commit comments