Author: Adam Pioterek <adam.pioterek@protonmail.ch>
gtfs download: request is more standard (ETag -> If-None-Match)
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/ml/adamsprogs/bimba/datasources/TimetableDownloader.kt b/app/src/main/java/ml/adamsprogs/bimba/datasources/TimetableDownloader.kt index 516d4022d9b5c77323c63dc73aa0b02252f5319d..ec07e8287e99776930285e6639bdf06a5d226789 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/datasources/TimetableDownloader.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/datasources/TimetableDownloader.kt @@ -42,7 +42,7 @@ try { try { val url = URL("https://adamsprogs.tk/gtfs") httpCon = url.openConnection() as HttpsURLConnection - httpCon.addRequestProperty("ETag", localETag) //todo if not matches + httpCon.addRequestProperty("If-None-Match", localETag) httpCon.connect() } catch (e:SSLException) { val url = URL("http://adamsprogs.tk/gtfs") @@ -105,9 +105,10 @@ sendBroadcast(broadcastIntent) } private fun notify(progress: Int, titleId: Int, messageId: Int, sizeCompressed: Int, sizeUncompressed: Int) { - val quotient = sizeCompressed.toFloat() / sizeUncompressed.toFloat() + /*val quotient = sizeCompressed.toFloat() / sizeUncompressed.toFloat() val message = getString(messageId, Math.max(progress * quotient, sizeCompressed.toFloat()), - sizeCompressed, (progress.toFloat() / sizeUncompressed.toFloat()) * 100) + sizeCompressed, ((progress.toFloat() / sizeUncompressed.toFloat()) * 100)) fixme format error*/ + val message = "" val title = getString(titleId) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) notifyCompat(progress, title, message, sizeUncompressed) diff --git a/converter/gtfs.php b/converter/gtfs.php index 8a4195475aada7d52d867d2e9ab3bb176e033637..58d0e7a2287ab6b41a8d0a100216b76f80d77366 100644 --- a/converter/gtfs.php +++ b/converter/gtfs.php @@ -20,7 +20,7 @@ } } unset($row); -$etag = $_SERVER['HTTP_ETAG']; +$etag = $_SERVER['HTTP_IF_NONE_MATCH']; if ($etag == $current) { http_response_code(304);