Changelog - 2026-11-03
RequestBodyEncoder types its body, and ResponseReader reads a file name
New Feature EnhancementIn one line. RequestBodyEncoder.encode now says what body it built, so a FormData goes to an API that takes string | object without a cast, and ResponseReader.readFilename gives you the file name of a download.
The example is in Encode a body and read a file name yourself.
What changed
- A typed body.
encode({ bodyType, body })returnsbody: FormDataforform-dataandbody: URLSearchParamsforx-www-form-urlencoded. Forjson,none,binaryor nobodyTypeit returns the body you passed, with its type. AbodyTypethat is only astringstill givesbody: unknown. Nothing changes at run time. ResponseReader.readFilename({ headers }). It returns the name inContent-Disposition,filename*=(UTF-8, decoded) beforefilename=, orundefined.ResponseReader.readstill returns the name asfilenameand behaves as before.
Who is affected
- An app or a subclass of
DefaultNetworkRequestServicethat callsRequestBodyEncoder.encode. No action needed. If your code assigned thebodyto a variable typedunknown, it still compiles. - An app that parsed
Content-Dispositionitself. You can callResponseReader.readFilenameinstead.
See Network.