I'm developing an application that uses .pbf files that are sent from the server to Mapbox GL JS using the header 'Content-Encoding: gzip' from PHP and am now trying to emulate the same behaviour for tiles from the storage.
Now I can't do this in a similar way as to how I'm trying to pass through the tiles from the storage of the android because whenever I add the header to the response, it immediately rejects with the following rejection message:
{
"config": {
"transformRequest": {},
"transformResponse": {},
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"headers": {
"Accept": "application/json, text/plain, */*"
},
"method": "get",
"Access-Control-Allow-Origin": "*",
"Accept": "*/*",
"url": "http://localhost:8080/get-tile/14/8468/5344"
},
"request": {
"statusText": "",
"status": 0,
"responseURL": "",
"response": "",
"responseType": "",
"responseXML": null,
"responseText": "",
"upload": {
"ontimeout": null,
"onprogress": null,
"onloadstart": null,
"onloadend": null,
"onload": null,
"onerror": null,
"onabort": null
},
"withCredentials": false,
"readyState": 4,
"timeout": 0,
"onprogress": null,
"onloadstart": null,
"onloadend": null,
"onload": null,
"onabort": null
}
}
When I do not use the header; the response sends fine and shows the still compressed data, which Mapbox GL JS doesn't understand. Now, I've tried to use GZIPOutputStream and GZIPInputStream in order to read the file and deflate it to get the right data, but it keeps showing me errors relating to either the header of the file itself being incorrect or it not being of a GZIP type (Which.. would be weird considering serving the same binary blob from PHP using Content-Encoding: gzip
as a supporting header works fine).
So far what I've tried is the following:
- Add the header (this results in request being rejected with the json above)
- Use different Inputstream / Outputstreams in order to read the data
- gzdecompress / gzdecode on the PHP side (running PHP 7 on WampServer x64 on Windows 10, this throws a data error)
- Inspect the files with a Hex Editor to see the difference between a working tile and a non functioning compressed tile Link to a drive with the files, both from the same server one with the Header on and one with it off
- Attempt to gzip unpacking on the javascript side (This results in pretty much nothing happening)
I'm retrieving the tile using axios in a modified Mapbox GL JS environment, loading the tile straight from the server works and draws the map data perfectly. However when it's served from the local storage through a http server it won't work.