openanalytics / shinyproxy

ShinyProxy - Open Source Enterprise Deployment for Shiny and data science apps
https://www.shinyproxy.io
Apache License 2.0
525 stars 151 forks source link

Try to fix gzip content #498

Closed mnival closed 5 months ago

mnival commented 6 months ago

Hello, After updating from shinyproxy version 2.6.1 to 3.1.0 some pages were no longer displayed properly. What I noticed was that the Content-Encoding was no longer present in the response.

With 3.1.0: image

With 2.6.1: image

I am attaching a possible PR which resolves my problem and I have not noticed any regression in my applications but I was able to omit tests. I'll let you see if my PR is acceptable or not and if not I'm open to any other solution that would allow me to use the latest version.

Thank you

Regards,

LEDfan commented 5 months ago

Hi, thank you for opening this PR! I think your solution solves the problem, but when the response is compressed, the iframe script will not be injected. This script is required for some features of ShinyProxy, such as heartbeats and detecting app crashes. I implemented a different change: ShinyProxy now sends the "Accept-Encoding: identity" header, which should force the app to not use compression. Can you test whether this solves the issue for you?

mnival commented 5 months ago

Hello, Unfortunately it's the same result. I continued the analysis and it seems that the problem is not only the content-encoding. The file is encoded in text/html; charset=utf-16le but the response forces a utf-8 format. image

I uploaded my file to a web server and I have the content and it does not provide the encoding when responding: image

I checked directly in my Shiny App and the content is forced to utf-8, so finally it seems the problem is on my shinyapp.

I think that Accept-Encoding: identity is still a good option but unfortunately it does not solve my problem which does not seem to be in ShinyProxy even if version 2 hid this problem.

So I think we can close this PR, unless you have another idea :)

Regards,

LEDfan commented 5 months ago

Thanks for the additional research. I'm afraid that if Shiny does not support loading and serving UTF-16 files, ShinyProxy cannot fix this. In principle ShinyProxy also assumes that the response is UTF-8 encoded, since this is more or less the default encoding of the web nowadays. I'm going to close this, but if you have any other suggestion, feel free to open a new issue/pr!