From: Keith Packard Date: Sun, 11 Aug 2024 22:40:49 +0000 (-0700) Subject: altoslib: Ignore content-length when fetching map tiles X-Git-Tag: 1.9.20~1^2~37 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=3e300bb8f6ddd735236103527d8d78b9dc87e0fd;p=fw%2Faltos altoslib: Ignore content-length when fetching map tiles Apache has been "fixed" to no longer respect any content-length provided by a CGI script. This means we don't get the length of the image from the server anymore. Ignore it and just keep fetching until we hit the end. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosMapStore.java b/altoslib/AltosMapStore.java index f852f560..a2221ac4 100644 --- a/altoslib/AltosMapStore.java +++ b/altoslib/AltosMapStore.java @@ -131,20 +131,15 @@ public class AltosMapStore { } InputStream in = new BufferedInputStream(uc.getInputStream()); int bytesRead = 0; - int offset = 0; - data = new byte[contentLength]; - while (offset < contentLength) { - bytesRead = in.read(data, offset, data.length - offset); - if (bytesRead == -1) - break; - offset += bytesRead; + byte[] buffer = new byte[4096]; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + while ((bytesRead = in.read(buffer)) != -1) { + baos.write(buffer, 0, bytesRead); } in.close(); + data = baos.toByteArray(); - if (offset == contentLength) - status = AltosMapTile.fetched; - else - status = AltosMapTile.failed; + status = AltosMapTile.fetched; } catch (IOException e) { status = AltosMapTile.failed;