Skip to content

🐛 Report the final URL as a redirect in native_dio_adapter - #2630

Open
krokyze wants to merge 1 commit into
cfug:mainfrom
krokyze:fix/native-adapter-redirect-url
Open

krokyze wants to merge 1 commit into
cfug:mainfrom
krokyze:fix/native-adapter-redirect-url

Conversation

@krokyze

@krokyze krokyze commented Oct 28, 2026 •

Copy link
Copy Markdown

Closes #2631

cupertino_http and cronet_http follow redirects natively and expose the final URL through BaseResponseWithUrl, but ConversionLayerAdapter never passed it on. So with NativeAdapter, Response.realUri stayed the request URL and Response.redirects was always empty after a redirect.

This adds a single RedirectRecord with the final URL when it differs from the request URL. The native clients don't expose the intermediate hops or their status codes, so the record uses 302 and the request method. That's enough for realUri to be right, but redirects won't list every hop like IOHttpClientAdapter does. Happy to change the status code if you'd prefer something else.

@cfug/dio-core this touches redirect handling, so flagging it as the guidelines ask.

Added three tests to conversion_layer_adapter_test.dart: a redirected response (fails without the change), a response whose URL didn't change, and a response that doesn't report a URL. flutter test and dart analyze in plugins/native_dio_adapter pass.

Unverified: I didn't run it against a real redirect on a device.

Implementation and tests written with Claude Code; I reviewed and ran them.

New Pull Request Checklist

  • I have read the Documentation
  • I have read the Agent Contribution Guidelines (required if any part of the change was produced with AI assistance)
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary) (not applicable — no public API change)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

cupertino_http and cronet_http follow redirects natively and expose the
final URL through BaseResponseWithUrl, but ConversionLayerAdapter never
passed it on, so Response.realUri stayed the request URL and
Response.redirects was always empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@krokyze
krokyze marked this pull request as ready for review October 28, 2026 19:55
@krokyze
krokyze requested a review from a team as a code owner October 28, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native_dio_adapter: Response.realUri is always the request URL after a redirect

1 participant