Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,75 +67,6 @@ public String getName() {
return ABC_CORE_JS_UI_MODULE;
}

@ReactMethod
public void fetch(
String url, String method, String body, ReadableArray headers, Promise promise) {
StringBuffer stringBuffer = new StringBuffer("");
BufferedReader bufferedReader = null;
HttpsURLConnection urlConnection = null;
Log.d(TAG, method + ": " + url + " ");
for (int i = 0; i < headers.size(); i++) {
Log.d(TAG, "header: " + headers.getString(i));
}
try {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, null, null);

URL sendUrl = new URL(url);
urlConnection = (HttpsURLConnection) sendUrl.openConnection();
urlConnection.setSSLSocketFactory(context.getSocketFactory());

for (int i = 0; i < headers.size(); i++) {
String[] property = headers.getString(i).split("______");
urlConnection.setRequestProperty(property[0], property[1]);
}

urlConnection.setRequestMethod(method);
if ("POST".equalsIgnoreCase(method)) {
urlConnection.setRequestProperty(
"Content-Length", "" + Integer.toString(body.getBytes().length));
urlConnection.setUseCaches(false);
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
}

if ("POST".equalsIgnoreCase(method)) {
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.writeBytes(body);
wr.flush();
wr.close();
}

InputStream in = new BufferedInputStream(urlConnection.getInputStream());
bufferedReader = new BufferedReader(new InputStreamReader(in));
String readLine = bufferedReader.readLine();
while (readLine != null) {
stringBuffer.append(readLine);
stringBuffer.append("\n");
readLine = bufferedReader.readLine();
}
} catch (Exception e) {
e.printStackTrace();
promise.reject(e);
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String temp = stringBuffer.toString();
if (temp == null) {
temp = "{}";
}
promise.resolve(temp);
}

@ReactMethod
public void supportsTouchId(Promise promise) {
promise.resolve(checkHardwareSupport());
Expand Down
2 changes: 0 additions & 2 deletions packages/edge-login-ui-rn/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @flow

import './util/androidFetch.js'

export * from './components/publicApi/ChangePasswordScreen.js'
export * from './components/publicApi/ChangePinScreen.js'
export * from './components/publicApi/ChooseTestAppScreen.js'
Expand Down
21 changes: 0 additions & 21 deletions packages/edge-login-ui-rn/src/util/androidFetch.js

This file was deleted.