@Override public void didFinishLoading(NSURLConnection conn) { platform.notifySuccess(callback, new ResponseImpl(rspCode) { @Override protected Map<String,List<String>> extractHeaders() { Map<String,List<String>> headerMap = new HashMap<String,List<String>>(); if (headers != null) { for (Map.Entry<String,String> entry : headers.entrySet()) { // iOS concatenates all repeated headers into a single header separated by commas, // which is known to be a fucking stupid thing to do, but hey, they're doing it! headerMap.put(entry.getKey(), Collections.singletonList(entry.getValue())); } } return headerMap; } @Override public String payloadString() { try { return new String(data.getBytes(), "UTF-8"); } catch (UnsupportedEncodingException uee) { throw new RuntimeException(uee); } } @Override public byte[] payload() { return data.getBytes(); } }); } }, true);
public void run () { try { platform.notifySuccess(callback, getBytesSync(path)); } catch (Throwable t) { platform.notifyFailure(callback, t); } } });
public void run () { try { platform.notifySuccess(callback, getTextSync(path)); } catch (Throwable t) { platform.notifyFailure(callback, t); } } });
if (encoding == null) encoding = UTF8; platform.notifySuccess(callback, new BinaryResponse(code, payload, encoding) { @Override protected Map<String,List<String>> extractHeaders() {
if (encoding == null) encoding = UTF8; platform.notifySuccess(callback, new BinaryResponse(code, payload, encoding) { @Override protected Map<String,List<String>> extractHeaders() {
platform.notifySuccess(callback, impl); } catch (Exception e) { platform.notifyFailure(callback, e);
platform.notifySuccess(callback, impl); } catch (Exception e) { platform.notifyFailure(callback, e);