Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Support Application Octet Stream #15

Closed
ProofOfKeags opened this issue Jun 4, 2020 · 3 comments · Fixed by #91
Closed

Support Application Octet Stream #15

ProofOfKeags opened this issue Jun 4, 2020 · 3 comments · Fixed by #91
Milestone

Comments

@ProofOfKeags
Copy link

Is your feature request related to a problem? Please describe.
The full scope of HTTP is not presently supported by this plugin. The plugin naively assumes all responses are either JSON or some other UTF8 encoded string. This removes the possibility of interacting with APIs that return data with Content-Type application/octet-stream`.

Describe the solution you'd like
I would like the type of the data field of the response to depend on the Content-Type. Specifically, if the Content-Type is application/json it should be of type {} or []. If the Content-Type is application/octet-stream it should return either a Blob or an ArrayBuffer.

This will require some unfortunately wasteful changes along the native bridge since as far as I understand, the capacitor<->native bridge only supports a data type that is isomorphic to JSON. This problem can be solved by either a Hex or Base64 expansion across the capacitor barrier which is then re-compacted into the desired type before leaving the TypeScript side of the plugin to the calling code.

Describe alternatives you've considered
As far as alternatives go, I think there are only 2 real considerations here. 1. Blob vs ArrayBuffer as a TypeScript exit type. 2. Base16 (alignment) vs Base64 (space efficiency) as a utf8 string encoding over the capacitor<->native bridge.

@mlynch
Copy link
Contributor

mlynch commented Jun 5, 2020

Thanks, yea that hasn't been implemented yet. You are correct about the serialization today, but we're thinking about ways we can somewhat natively support ArrayBuffer for the bridge (such as streaming it over an HTTP connection), but that will have to happen in core first. For now we would just do base64 most likely which isn't ideal but will at least add support for it.

@sta55en
Copy link

sta55en commented Jun 26, 2020

Is there any idea around timeline for this feature? Or perhaps, are there any plans to create ArrayBuffer in the bridge? I can see major performance improvements for many plugins and interactions with the native code if this is implemented.

@thomasvidas
Copy link
Contributor

Merged into the capacitor-v3 branch so I'm closing this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants