mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
Garmin: Fix 304 response when agps matches cache
This commit is contained in:
parent
ba9e5c8a77
commit
b704276e49
@ -50,6 +50,7 @@ public class AgpsHandler {
|
||||
}
|
||||
|
||||
final GarminHttpResponse response = new GarminHttpResponse();
|
||||
response.getHeaders().put("cache-control", "max-age=14400");
|
||||
|
||||
final byte[] rawBytes = FileUtils.readAll(agpsIn, 1024 * 1024); // 1MB, they're usually ~60KB
|
||||
final String fileHash = GB.hexdump(CheckSums.md5(rawBytes)).toLowerCase(Locale.ROOT);
|
||||
@ -62,9 +63,9 @@ public class AgpsHandler {
|
||||
LOG.debug("agps request hash = {}, file hash = {}", ifNoneMatch, etag);
|
||||
|
||||
if (etag.equals(ifNoneMatch)) {
|
||||
// FIXME: the 304 reboots some watches, so just ignore the request if the hash matches
|
||||
//response.setStatus(304);
|
||||
return null;
|
||||
response.setBody(new byte[0]);
|
||||
response.setStatus(304);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class HttpHandler {
|
||||
}
|
||||
|
||||
return GdiHttpService.HttpService.RawResponse.newBuilder()
|
||||
.setStatus(GdiHttpService.HttpService.Status.OK)
|
||||
.setStatus(response.getStatus() / 100 == 2 ? GdiHttpService.HttpService.Status.OK : GdiHttpService.HttpService.Status.UNKNOWN_STATUS)
|
||||
.setHttpStatus(response.getStatus())
|
||||
.setBody(ByteString.copyFrom(responseBody))
|
||||
.addAllHeader(responseHeaders)
|
||||
|
Loading…
Reference in New Issue
Block a user