Skip to content

fix(android): handle lowercase range header#8368

Merged
OS-pedrogustavobilro merged 3 commits intoionic-team:mainfrom
Maroon-Rides:fix/range-header
Mar 3, 2026
Merged

fix(android): handle lowercase range header#8368
OS-pedrogustavobilro merged 3 commits intoionic-team:mainfrom
Maroon-Rides:fix/range-header

Conversation

@bwees
Copy link
Copy Markdown
Contributor

@bwees bwees commented Mar 1, 2026

This fixes issues with HTTP range requests when the range header is lowercase on Android.

iOS handles the case insensitivity via urlSchemeTask.request.value(forHTTPHeaderField: "Range"). However on Android, headers are placed in a case sensitive Map that requires manual handling.

@bwees bwees changed the title fix: handle lowercase range header fix(android): handle lowercase range header Mar 1, 2026
@OS-pedrogustavobilro OS-pedrogustavobilro self-assigned this Mar 2, 2026
@OS-pedrogustavobilro
Copy link
Copy Markdown
Contributor

Hey @bwees, thanks for the PR.

I'm not getting any issues with the current code in main. I'm sending a lowercase "range" header, and it's still arriving "Range" to native Android, I assume Chrome does some capitalization of headers names.

Were you getting an issue with a particular request or situation? And if so can you share a reproduction app for us to check?

@bwees
Copy link
Copy Markdown
Contributor Author

bwees commented Mar 2, 2026

I am getting this issue when working with MapLibre GL JS and using PMTiles as a source.

An example app is here: https://github.com/bwees/range-request-capacitor-repro

If you look at the PMTiles responses received by the client (viewed from Chrome Devtools debugging the running android app), you will see that the proper range response headers are only sent once these changes are added.

On main, the "server" responds with a 200 response instead of a 206 response. Once this PR is applied, the responses come back as 206 with the Range specific headers in the response.

Note: Even with this fix, the map will not load as HTTP Range requests are quite broken on Capacitor. They do not currently follow spec which causes issues with the PMTiles decoder. I narrowed down the issue late last night, #8371 .

OS-pedrogustavobilro added a commit to OS-pedrogustavobilro/test-cap-issue-8367-regression-android-range that referenced this pull request Mar 3, 2026
Copy link
Copy Markdown
Contributor

@OS-pedrogustavobilro OS-pedrogustavobilro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwees I wasn't able to check with your reproduction app, but I went back to a test app I had and was able to reproduce this issue now (without this fix was getting 200, now getting 206).

I think I wasn't able to reproduce a few days ago when I was testing with an Android 12 device, but tested now with Android 16 and getting the error. Strange because they have the same System WebView version, but maybe it's something in the OS that made the behavior different. Anyway, this fix does it.

I suggest you to re-look at the reproduction app, especially to test the other issue you shared. It fails when running npm run build, missing some UI files I think. I tried to add some, the map loaded but still wasn't getting range requests, so maybe it needs specific configuration.

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit ae0e2dd into ionic-team:main Mar 3, 2026
5 of 6 checks passed
@bwees
Copy link
Copy Markdown
Contributor Author

bwees commented Mar 3, 2026

Hey sorry about that! It appears I must have deleted the wrong map components while stripping my app to a minimum example. I have updated it and pushed to the branch so #8371 should be easy to reproduce now.

Thanks for your help!

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.

2 participants