refactor(fetch): make Body extend Blob#51
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesBody extends Blob + Stream refactor
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Body
participant Blob
participant StreamHost
Note over Caller,StreamHost: Blob-backed read path
Caller->>Body: arrayBuffer()
Body->>Blob: super.arrayBuffer()
Blob-->>Body: ByteBuffer
Body-->>Caller: ByteBuffer
Note over Caller,StreamHost: Stream-backed read path
Caller->>Body: arrayBuffer()
Body->>StreamHost: _readStream(_streamHost)
StreamHost-->>Body: accumulated Uint8List chunks
Body-->>Caller: ByteBuffer
Note over Caller,StreamHost: clone() on stream-backed body
Caller->>Body: clone()
Body->>Body: streamTee(_streamHost)
Body-->>Body: update _streamHost with tee[0]
Body-->>Caller: new Body with tee[1] as _streamHost
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7a57bf979
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f7a57bf to
8349abd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8349abd386
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| final URLSearchParams _ => _urlEncodedUtf8, | ||
| final Blob blob => blob.type, | ||
| final block.Block blockHost => blockHost.type, | ||
| _ => '', |
There was a problem hiding this comment.
Preserve native Blob content types
When users pass a native web.Blob or web.File directly as BodyInit on the web target, Blob now accepts and reads that host-backed part, but this fallback leaves the type as '', so Body(web.Blob(...type: 'text/plain')).contentType is null. Request/Response only auto-populate the content-type header from body.contentType, so these accepted native Blob/File bodies lose their MIME type even though package Blob bodies still preserve it; please extract the host Blob/File type when delegating these inputs.
Useful? React with 👍 / 👎.
Type
Refactor
Summary
Bodyextend the conditional platformBlobimplementation and implementStream<Uint8List>directly.Bodyconstruction by delegating Blob-compatible inputs toBlob, while keepingBody,FormData, and stream-specific handling inBody.bodyUsedsemantics, and update public surface coverage for the new inheritance shape.Notes
Bodynow depends on the conditionalblob.dartsurface rather than importingblob.native.dartdirectly.Validation
dart format --output=none --set-exit-if-changed .dart analyzedart test -p vm -p node -p chromeCloses #50
Summary by CodeRabbit
Release Notes
Breaking Changes
Body.streamis now a method with an optionalchunkSizeparameter; usebody.stream()instead ofbody.stream.Body.sizemay throwUnsupportedErrorfor stream-backed bodies with unknown length.Bodynow extendsBloband implementsStream<Uint8List>.Documentation
BodyAPI and interface hierarchy.