0

I install no my MacOs HighSierra fresh XAMPP (osx-7.4.6-0-vm) and start it - server runs on IP 192.168.64.2 . Then I mount /opt/lampp and click to Explore. The Finder window open and I go to directory htdocs/. Then inside htdocs I create folder assets and inside it I copy file alice.wasm (this file is compressed using brotli (br)). You can download this test (brotli compressed) file using this jsfiddle generator. Inside htdocs I create following .htaccess file

<IfModule mod_mime.c>
  AddType application/wasm .wasm
  AddEncoding br .wasm
  AddOutputFilterByType DEFLATE application/wasm
</IfModule>

Problem

When I go to http://192.168.64.2/assets/alice.wasm browser not download file and in chrome>networks tab I see (here are more details)

(failed) net::ERR_CONTENT_DECODING_FAILED

However, when I change AddEncoding br .wasm to AddEncoding rar .wasm (or instead 'br' I use zip, or none) then browser download file (details) but the problem is that browser automatically NOT decompress file (so it save compressed file).

When I put this .htacces file and alice.wasm file to some AZURE apache-like server (but I don't have access to it configuration files) then browser download file and decompress it on the fly (details) - so this is POSSIBLE.

Question: What I should do to make XAMPP working as expected?

Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345
  • Why are you trying to add the `DEFLATE` handler, when your content is supposed to be Brotli-compressed already? You do not actually want to add an additional layer of `gzip` encoding here, do you? – CBroe Jun 15 '20 at 08:06
  • @CBroe when I remove `AddOutputFilterByType DEFLATE application/wasm` the problem is still the same. Interesting thing (independent of that modification): firefox download file (with status 200 and `content-encoding: br` like in AZURE) but not decompress it (chrome not download it at all) – Kamil Kiełczewski Jun 15 '20 at 08:38
  • I think the `content-encoding: br` part from your last screenshot, is the most important thing here. Check if the response headers contain that, with your attempt. (I suppose Firefox should show you those headers, if it actually downloads the file. Chrome appears to cancel _everything_ once it has determined that it can not decode the request body to begin with.) – CBroe Jun 15 '20 at 08:43
  • @CBroe - yes firefox shows that header - but Chrome show [this](https://imgur.com/a/fG6t2PB) and [this](https://imgur.com/a/VzuRQIg) – Kamil Kiełczewski Jun 15 '20 at 08:59

2 Answers2

1

brotli module works only on HTTPS mod. See it here: why does not brotli work on http?. If you have ssl certificate, it will work there.

Ziaur Rahman
  • 1,148
  • 11
  • 24
0

It is very strange, but when I enable port forwarding

enter image description here

And go to http://localhost:8080/assets/alice.wasm then Chrome download file and automatically decompress it (exactly what I want). AZURE works on HTTPS and file was downloaded properly probably because brotli compression is support only for HTTPS - however probably on Chrome localhost is 'special' and allows it too.

enter image description here

Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345