Skip to content

Conversation

@adrientimmer
Copy link
Contributor

Description

It seems like IONFLTRController.kt#L289 is explicitly setting the Accept-Encoding header's value to gzip which results in responses from servers supporting response compression to be encoded. This however doesn't seem to be correctly handled in processUploadResponse which just reads the connection's input stream as text (connection.inputStream.bufferedReader().readText()). This unfortunately results in the responseBody being returned as a byte array converted to a string which isn't of much use.
I believe this is also the cause of ionic-team/capacitor-file-transfer#26

Android's HttpURLConnection documentation indicates that specifically setting the Accept-Encoding header value disables automatic compression:

Setting the Accept-Encoding request header explicitly disables automatic decompression and leaves the response headers intact; callers must handle decompression as needed, according to the Content-Encoding header of the response.

Removing this header value leads to the response being automatically decompressed and returned correctly but it isn't yet clear as to why it was needed in the first place.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Tests

This was tested by uploading a file to an endpoint which respects the Accept-Encoding header value and returns a response body encoded to suit the request's desired encoding.

Screenshots (if appropriate)

Checklist

  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

…der value as it disables automatic response decompression
@adrientimmer
Copy link
Contributor Author

@ItsChaceD , @OS-pedrogustavobilro Apologies if this is a duplicate notification or if you're the wrong people to notify but I'm not sure if you folks have notifications setup for unassigned PRs but I can't seem to assign reviewers to it (I'm not even sure outside PRs are accepted).

@OS-pedrogustavobilro OS-pedrogustavobilro self-assigned this Dec 22, 2025
Copy link
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.

Hey @adrientimmer thanks for the PR. I did some missing changes and will be merging this PR now.

I believe this gzip encoding was ported from a Cordova Plugin, but from what I checked here we have no need for it, the download/upload progress computation seems to still be correct.

Thank you!

@OS-pedrogustavobilro OS-pedrogustavobilro changed the title Removed explicit setting of HttpURLConnection Accept-Encoding header value as it disables automatic response decompression fix: Removed explicit setting of HttpURLConnection Accept-Encoding header value as it disables automatic response decompression Dec 22, 2025
@OS-pedrogustavobilro OS-pedrogustavobilro merged commit c0004f2 into ionic-team:main Dec 22, 2025
1 check passed
OS-pedrogustavobilro added a commit to ionic-team/capacitor-file-transfer that referenced this pull request Dec 22, 2025
OS-pedrogustavobilro added a commit to ionic-team/capacitor-file-transfer that referenced this pull request Dec 22, 2025
* chore: show whole error in example app

Not related to the IONIC-53 issue, but helpful to debug.

* fix(android): correct upload response by removing gzip encoding

Fix in native library.

References:

- ionic-team/ion-android-filetransfer#10
- https://outsystemsrd.atlassian.net/browse/IONIC-53
OS-pedrogustavobilro added a commit to ionic-team/capacitor-file-transfer that referenced this pull request Dec 22, 2025
* chore: show whole error in example app

Not related to the IONIC-53 issue, but helpful to debug.

* fix(android): correct upload response by removing gzip encoding

Fix in native library.

References:

- ionic-team/ion-android-filetransfer#10
- https://outsystemsrd.atlassian.net/browse/IONIC-53
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