mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Garmin: Fix exception if http request has no headers
This commit is contained in:
+6
-4
@@ -41,11 +41,13 @@ public class GarminHttpRequest {
|
|||||||
this.webRequest = webRequest;
|
this.webRequest = webRequest;
|
||||||
this.method = webRequest.getMethod().name();
|
this.method = webRequest.getMethod().name();
|
||||||
this.uri = Uri.parse(webRequest.getUrl());
|
this.uri = Uri.parse(webRequest.getUrl());
|
||||||
final JsonElement garminHeaders = GarminJson.decode(webRequest.getHeaders().toByteArray());
|
|
||||||
this.headers = new LinkedHashMap<>();
|
this.headers = new LinkedHashMap<>();
|
||||||
if (garminHeaders instanceof JsonObject jsonObject) {
|
if (!webRequest.getHeaders().isEmpty()) {
|
||||||
for (String key : jsonObject.keySet()) {
|
final JsonElement garminHeaders = GarminJson.decode(webRequest.getHeaders().toByteArray());
|
||||||
headers.put(key, jsonObject.get(key).getAsString());
|
if (garminHeaders instanceof JsonObject jsonObject) {
|
||||||
|
for (String key : jsonObject.keySet()) {
|
||||||
|
headers.put(key, jsonObject.get(key).getAsString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user