| 186 | }); |
| 187 | |
| 188 | function checkGzipAndNext(req, res, next) { |
| 189 | const baseURL = `${req.protocol}://${req.headers.host}/`; |
| 190 | const reqUrl = new URL(req.url, baseURL); |
| 191 | const filePath = reqUrl.pathname.substring(1); |
| 192 | |
| 193 | const readStream = fs.createReadStream(filePath, { start: 0, end: 2 }); |
| 194 | //eslint-disable-next-line no-unused-vars |
| 195 | readStream.on("error", function (err) { |
| 196 | next(); |
| 197 | }); |
| 198 | |
| 199 | readStream.on("data", function (chunk) { |
| 200 | if (chunk.equals(gzipHeader)) { |
| 201 | res.header("Content-Encoding", "gzip"); |
| 202 | } |
| 203 | next(); |
| 204 | }); |
| 205 | } |
| 206 | |
| 207 | const knownTilesetFormats = [ |
| 208 | /\.b3dm/, |