RunOnFlux / flux

Flux, Your Gateway to a Decentralized World. https://home.runonflux.io https://api.runonflux.io https://docs.runonflux.io https://source.runonflux.io https://wiki.runonflux.io
https://home.runonflux.io
GNU Affero General Public License v3.0
232 stars 309 forks source link

Don't compress response if the x-no-compression header is present #1376

Closed sygem closed 3 months ago

sygem commented 3 months ago

Several FluxOS endpoint use server-sent events to show progress to the user. For example '/apps/testappinstall/' details the install process as it goes.

I have been unable to get Flutter to read these streams, and managed to track the problem down to the express compression plugin.

This solution allows a client to send a "x-no-compression" header with the request to disable the response compression. If no such header is sent, compression will take place as normal. I am then able to read the SSE streams in Flux Cloud.

MorningLightMountain713 commented 3 months ago

@sygem @Cabecinha84

We don't need to do this...

The compression middleware allows for this already:

This middleware will never compress responses that include a Cache-Control header with the [no-transform directive](https://tools.ietf.org/html/rfc7234#section-5.2.2.4), as compressing will transform the body.

Cabecinha84 commented 3 months ago

I have merged and tested on development node and I don't see any difference sending the x-no-compression header

Cabecinha84 commented 3 months ago

@sygem can you check against node http://94.16.104.218:16127/ (dev node with the changes already running) if it makes any difference? If not I will revert it. Please let me know ASAP

sygem commented 3 months ago

@sygem @Cabecinha84

We don't need to do this...

The compression middleware allows for this already:

This middleware will never compress responses that include a Cache-Control header with the [no-transform directive](https://tools.ietf.org/html/rfc7234#section-5.2.2.4), as compressing will transform the body.

I tried that, but couldn't get it to work with my Flutter tests.