| 206 | } |
| 207 | |
| 208 | private Object[] proxy1(Map<String, String> params) throws Exception { |
| 209 | JSObject obj = submit(() -> JSUtil.toObject(ctx, params)).get(); |
| 210 | JSArray proxy = (JSArray) call("proxy", obj); |
| 211 | String json = submit(proxy::stringify).get(); |
| 212 | JSONArray array = new JSONArray(json); |
| 213 | Map<String, String> headers = array.length() > 3 ? Json.toMap(array.optString(3)) : null; |
| 214 | boolean base64 = array.length() > 4 && array.optInt(4) == 1; |
| 215 | Object[] result = new Object[4]; |
| 216 | result[0] = array.optInt(0); |
| 217 | result[1] = array.optString(1); |
| 218 | result[2] = getStream(array.opt(2), base64); |
| 219 | result[3] = headers; |
| 220 | return result; |
| 221 | } |
| 222 | |
| 223 | private Object[] proxy2(Map<String, String> params) throws Exception { |
| 224 | String url = params.get("url"); |