braid-http 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/braid-http-client.js +10 -2
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -237,6 +237,11 @@ async function braid_fetch (url, params = {}) {
|
|
|
237
237
|
if (typeof params.parents === 'function')
|
|
238
238
|
params.headers.set('parents', params.parents().map(JSON.stringify).join(', '))
|
|
239
239
|
|
|
240
|
+
// undocumented feature used by braid-chrome
|
|
241
|
+
// to see the fetch args as they are right before it is actually called,
|
|
242
|
+
// to display them for the user in the dev panel
|
|
243
|
+
params.onFetch?.(url, params)
|
|
244
|
+
|
|
240
245
|
// Now we run the original fetch....
|
|
241
246
|
res = await normal_fetch(url, params)
|
|
242
247
|
|
|
@@ -279,7 +284,8 @@ async function braid_fetch (url, params = {}) {
|
|
|
279
284
|
on_error(err)
|
|
280
285
|
}
|
|
281
286
|
},
|
|
282
|
-
!isTextContentType(res.headers.get('content-type'))
|
|
287
|
+
!isTextContentType(res.headers.get('content-type')),
|
|
288
|
+
params.onBytes
|
|
283
289
|
)
|
|
284
290
|
}
|
|
285
291
|
|
|
@@ -368,7 +374,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
368
374
|
}
|
|
369
375
|
|
|
370
376
|
// Parse a stream of versions from the incoming bytes
|
|
371
|
-
async function handle_fetch_stream (stream, cb, binary) {
|
|
377
|
+
async function handle_fetch_stream (stream, cb, binary, on_bytes) {
|
|
372
378
|
if (is_nodejs)
|
|
373
379
|
stream = to_whatwg_stream(stream)
|
|
374
380
|
|
|
@@ -395,6 +401,8 @@ async function handle_fetch_stream (stream, cb, binary) {
|
|
|
395
401
|
return
|
|
396
402
|
}
|
|
397
403
|
|
|
404
|
+
on_bytes?.(value)
|
|
405
|
+
|
|
398
406
|
// Tell the parser to process some more stream
|
|
399
407
|
parser.read(value)
|
|
400
408
|
}
|