ITADN

onAborted + onData -> new single onStream callback

#1245OpenuNetworkingAB 创建于 2026-03-15
U
uNetworkingABcommented
Since onData is now considered stupid, and onAborted could easily be inferred from onData arguments, I want a new single callback that manages both in 1 call: onStream((chunk, maxRemainingBodyLength) => { // if chunk is null you have aborted // if maxRemainingBodyLength is 0 you have reached the end successfully // you can safely preallocate using maxRemainingBodyLength (it is infinity for chunked mode, so buffering logic is the same for chunk/content-length) }) This one callback makes it OBVIOUS when you need to attach a callback and when you don't need to. No more onAborted error messages that makes no sense - either you end the request "sync" and don't use any callbacks or you don't end it, and therefore logically MUST attach onStream (otherwise, wtf are you leaking async resources)
1 条评论