File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 436436 'Authorization' : 'Nostr ' + token
437437 } ;
438438
439+ // Collect body if it's an async iterable
440+ let requestBody = body ;
441+ if ( body && typeof body [ Symbol . asyncIterator ] === 'function' ) {
442+ const chunks = [ ] ;
443+ for await ( const chunk of body ) {
444+ chunks . push ( chunk ) ;
445+ }
446+ const totalLength = chunks . reduce ( ( sum , chunk ) => sum + chunk . length , 0 ) ;
447+ requestBody = new Uint8Array ( totalLength ) ;
448+ let offset = 0 ;
449+ for ( const chunk of chunks ) {
450+ requestBody . set ( chunk , offset ) ;
451+ offset += chunk . length ;
452+ }
453+ }
454+
455+ console . log ( `HTTP ${ method } ${ url } ` , { bodySize : requestBody ?. length } ) ;
456+
439457 // Make the request
440458 const res = await fetch ( url , {
441459 method,
442460 headers : authHeaders ,
443- body
461+ body : requestBody
444462 } ) ;
445463
446464 // Return response in format isomorphic-git expects
447465 const responseBody = new Uint8Array ( await res . arrayBuffer ( ) ) ;
466+ console . log ( `Response ${ res . status } :` , { bodySize : responseBody . length } ) ;
448467
449468 return {
450469 url : res . url ,
You can’t perform that action at this time.
0 commit comments