From abec54fb1a5e5164441db1347daaf63ae57865b6 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 26 Sep 2022 11:52:24 +0100 Subject: [PATCH] Bangle.js: Added PATCH HTTP request type, and fix for VolleyError UnsupportedOperationException when supplying custom headers --- .../service/devices/banglejs/BangleJSDeviceSupport.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java index e554af6f1..da8d0052b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java @@ -568,6 +568,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { else if (m.equals("post")) method = Request.Method.POST; else if (m.equals("head")) method = Request.Method.HEAD; else if (m.equals("put")) method = Request.Method.PUT; + else if (m.equals("patch")) method = Request.Method.PATCH; else if (m.equals("delete")) method = Request.Method.DELETE; else uartTxJSONError("http", "Unknown HTTP method "+m,id); } @@ -640,7 +641,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { @Override public Map getHeaders() throws AuthFailureError { - Map h = super.getHeaders(); + // clone the data from super.getHeaders() so we can write to it + Map h = new HashMap<>(super.getHeaders()); if (headers != null) { Iterator iter = headers.keySet().iterator(); while (iter.hasNext()) {