-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable gzip encoding for capcitor http #6387
Conversation
@nimo23 sorry for the late reaction, i didn't had the time to work on it. But I fixed the branch and the code should be working like this. |
@ItsChaceD any chance for a review? |
* Use this option if you need a gzip compression of the data payload | ||
* A compatible consumer interface must be ensured. The default is _false_. | ||
*/ | ||
gzipCompression?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be an on/off setting that is applied for the entire lifecycle of the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will probably move this to a param in the http function call, this makes sense not to have it globally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of just doing copy-pasta of a source file from another open source project personally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will include the library into the project
options.headers['Content-Encoding'] = 'gzip'; | ||
output.headers = options.headers; | ||
|
||
const gzippedData: Uint8Array = Pako.gzip(options.data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of adding this dependency to core. Is there a reason you can't just gzip and gunzip on the client side from javascript on your side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the thing is that we could do that, but why we switched to capacitor http is, that we need background functionality of the http services and therefore we started using capacitor-community/http which brought us here. The Pako compression could be done client side in the app code, but we moved it to the web part of the plugin to complete the gzip functionality for all platforms. I didn't find any good code example to do it without Pako, maybe this dependency can be kept?
There are also pretty big changes to http via PR #6818 that more or less avoids using the related http plugin code at all in certain cases |
@Steven0351 I read your concerns and i have the rest of my team behind me to fix the issues, at least most of them, i hope we can find a solution that fits everyones needs. we isolated some tasks and we're on it, i think we can do it by the end of the week. I think you are trying to merge as much as possible to the capacitor 6 release, so we understood that we probably have to be quick now. I will respond to the rest in the related comments |
we will try to merge the other feature branch and see if its compatible here |
Before you put much more work into this, I'll bring this up to the core team. I personally don't see this making in for Cap 6, but that's not my call to make. |
@Steven0351 thanks for the warning. Then maybe text here if you know more. We would love to see this in cap6 since we live from fork to fork for the last two years ;-) |
Would be really nice to have this kind of standard feature in the core. |
Going to level-set expectations here and relay that this PR is not going to be accepted according to discussions with the core team. The features and functions you are requesting and suggesting being made available can be achieved by building a plugin to handle those specific cases. Compressing a request body is not standard browser behavior, so I'm not sure this feature is warranted in core for the http plugin. |
Hey, just chiming in here, I've been silently watching this PR for a while now as being able to compress the body of a HTTP request is a feature that would be a really vital for us to have.
Either way, from my standpoint I originally tried to compress the body of my HTTP requests using the I would be fine with the plugin not supporting compression as a feature if there is a way to tell the native HTTP plugin to simply send the payload raw as it is instead of transforming it in some way. |
Out of curiosity, what do you gain out of native http if you have some amount of control over the backend? |
Hey, sorry for getting back to this so late. That said, can't speak for other projects that may have some requirements that require the use of the plugin. But creating a custom plugin in those cases with some additional features they need wouldn't be all that hard to do. |
Thanks @Steven0351. Unfortunately only JSON and string is supported as data type for the request according to https://capacitorjs.com/docs/apis/http#httpoptions. Would this approach have better chances to pass your review? |
I talked it over with the core team and we're more positive on supporting arraybuffer. It adds a potential footgun if trying to encode large amounts of data, but overall I agree with your assessment about adding that support. |
Sounds great, @Steven0351. |
The scope for the next two releases has already been planned and are large efforts. The core team is now only a handful of people that are spread pretty thin. I personally focus on Portals and chip into Capacitor where it makes sense. If you want it in sooner than later, I would suggest a new community driven PR that we can review. I'd be more than happy to provide pointers or suggestions. I'm going to go ahead and close this PR since the work done as-is isn't a good fit for core, but thank you for everyones participation in this discussion. |
this is a follow up of capacitor-community/http#222 since the community plugin was not maintined anymore shortly after we opened that pull request.