diff options
| author | Rutger Broekhoff | 2026-09-10 23:10:57 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-09-10 23:11:03 +0200 |
| commit | 48a99fd71b11321b85c385245b5f2d36fed22df1 (patch) | |
| tree | eef558a1f8b5d69f9a1431d03f3999be66757fdc /web | |
| parent | a4408b5ac4ec10421bf9a7d5bf277946ec9f786e (diff) | |
| download | routemon-48a99fd71b11321b85c385245b5f2d36fed22df1.tar.gz routemon-48a99fd71b11321b85c385245b5f2d36fed22df1.zip | |
Fun with (raw) deflate
Diffstat (limited to 'web')
| -rw-r--r-- | web/index.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/web/index.js b/web/index.js index c6fb3f7..e8accf0 100644 --- a/web/index.js +++ b/web/index.js | |||
| @@ -102,12 +102,25 @@ async function getSysinfo() { | |||
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | async function load(gpxFile) { | 104 | async function load(gpxFile) { |
| 105 | let compressedParts = []; | ||
| 106 | const compressedReader = gpxFile.stream().pipeThrough(new CompressionStream("deflate-raw")).getReader(); | ||
| 107 | while (true) { | ||
| 108 | const { done, value } = await compressedReader.read(); | ||
| 109 | if (done) { | ||
| 110 | break; | ||
| 111 | } else { | ||
| 112 | compressedParts.push(value); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 105 | const rsp = await fetch(apiBaseUrl + "/gpx", { | 116 | const rsp = await fetch(apiBaseUrl + "/gpx", { |
| 106 | method: "POST", | 117 | method: "POST", |
| 107 | headers: { | 118 | headers: { |
| 108 | "Accept-Language": "nl-NL", | 119 | "Accept-Language": "nl-NL", |
| 120 | "Content-Encoding": "x-deflate-raw", | ||
| 121 | "Content-Type": "application/gpx+xml", | ||
| 109 | }, | 122 | }, |
| 110 | body: gpxFile, | 123 | body: new Blob(compressedParts), |
| 111 | }); | 124 | }); |
| 112 | if (!rsp.ok) { | 125 | if (!rsp.ok) { |
| 113 | await showProblem(rsp); | 126 | await showProblem(rsp); |