braid-http 1.0.0 → 1.0.2
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 +14 -4
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -234,8 +234,15 @@ async function braid_fetch (url, params = {}) {
|
|
|
234
234
|
|
|
235
235
|
// If parents is a function,
|
|
236
236
|
// call it now to get the latest parents
|
|
237
|
-
if (typeof params.parents === 'function')
|
|
238
|
-
|
|
237
|
+
if (typeof params.parents === 'function') {
|
|
238
|
+
let parents = params.parents()
|
|
239
|
+
if (parents) params.headers.set('parents', parents.map(JSON.stringify).join(', '))
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// undocumented feature used by braid-chrome
|
|
243
|
+
// to see the fetch args as they are right before it is actually called,
|
|
244
|
+
// to display them for the user in the dev panel
|
|
245
|
+
params.onFetch?.(url, params)
|
|
239
246
|
|
|
240
247
|
// Now we run the original fetch....
|
|
241
248
|
res = await normal_fetch(url, params)
|
|
@@ -279,7 +286,8 @@ async function braid_fetch (url, params = {}) {
|
|
|
279
286
|
on_error(err)
|
|
280
287
|
}
|
|
281
288
|
},
|
|
282
|
-
!isTextContentType(res.headers.get('content-type'))
|
|
289
|
+
!isTextContentType(res.headers.get('content-type')),
|
|
290
|
+
params.onBytes
|
|
283
291
|
)
|
|
284
292
|
}
|
|
285
293
|
|
|
@@ -368,7 +376,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
368
376
|
}
|
|
369
377
|
|
|
370
378
|
// Parse a stream of versions from the incoming bytes
|
|
371
|
-
async function handle_fetch_stream (stream, cb, binary) {
|
|
379
|
+
async function handle_fetch_stream (stream, cb, binary, on_bytes) {
|
|
372
380
|
if (is_nodejs)
|
|
373
381
|
stream = to_whatwg_stream(stream)
|
|
374
382
|
|
|
@@ -395,6 +403,8 @@ async function handle_fetch_stream (stream, cb, binary) {
|
|
|
395
403
|
return
|
|
396
404
|
}
|
|
397
405
|
|
|
406
|
+
on_bytes?.(value)
|
|
407
|
+
|
|
398
408
|
// Tell the parser to process some more stream
|
|
399
409
|
parser.read(value)
|
|
400
410
|
}
|