Skip to content

Commit

Permalink
fix: compile error in fix #404
Browse files Browse the repository at this point in the history
  • Loading branch information
silkimen committed Aug 20, 2021
1 parent 1dd5ee5 commit 1bafe6c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed #425: plugin crashes on Android SDK levels < 24
- Fixed #418: deprecated AFNetworking method causes app crash (thanks meiram-tr)
- Fixed #404: wrong timeout implementation (thanks YouYue123)

## 3.2.0

Expand Down
46 changes: 25 additions & 21 deletions src/android/com/silkimen/cordovahttp/CordovaHttpPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ private boolean executeHttpRequestWithoutData(final String method, final JSONArr

String url = args.getString(0);
JSONObject headers = args.getJSONObject(1);
int timeout = args.getInt(2) * 1000;
boolean followRedirect = args.getBoolean(3);
String responseType = args.getString(4);
int connectTimeout = args.getInt(2) * 1000;
int readTimeout = args.getInt(3) * 1000;
boolean followRedirect = args.getBoolean(4);
String responseType = args.getString(5);
Integer reqId = args.getInt(6);

Integer reqId = args.getInt(5);
CordovaObservableCallbackContext observableCallbackContext = new CordovaObservableCallbackContext(callbackContext, reqId);

CordovaHttpOperation request = new CordovaHttpOperation(method.toUpperCase(), url, headers, timeout, followRedirect,
responseType, this.tlsConfiguration, observableCallbackContext);
CordovaHttpOperation request = new CordovaHttpOperation(method.toUpperCase(), url, headers, connectTimeout, readTimeout,
followRedirect, responseType, this.tlsConfiguration, observableCallbackContext);

startRequest(reqId, observableCallbackContext, request);

Expand All @@ -123,15 +124,16 @@ private boolean executeHttpRequestWithData(final String method, final JSONArray
Object data = args.get(1);
String serializer = args.getString(2);
JSONObject headers = args.getJSONObject(3);
int timeout = args.getInt(4) * 1000;
boolean followRedirect = args.getBoolean(5);
String responseType = args.getString(6);
int connectTimeout = args.getInt(4) * 1000;
int readTimeout = args.getInt(5) * 1000;
boolean followRedirect = args.getBoolean(6);
String responseType = args.getString(7);
Integer reqId = args.getInt(8);

Integer reqId = args.getInt(7);
CordovaObservableCallbackContext observableCallbackContext = new CordovaObservableCallbackContext(callbackContext, reqId);

CordovaHttpOperation request = new CordovaHttpOperation(method.toUpperCase(), url, serializer, data, headers,
timeout, followRedirect, responseType, this.tlsConfiguration, observableCallbackContext);
connectTimeout, readTimeout, followRedirect, responseType, this.tlsConfiguration, observableCallbackContext);

startRequest(reqId, observableCallbackContext, request);

Expand All @@ -143,14 +145,15 @@ private boolean uploadFiles(final JSONArray args, final CallbackContext callback
JSONObject headers = args.getJSONObject(1);
JSONArray filePaths = args.getJSONArray(2);
JSONArray uploadNames = args.getJSONArray(3);
int timeout = args.getInt(4) * 1000;
boolean followRedirect = args.getBoolean(5);
String responseType = args.getString(6);
int connectTimeout = args.getInt(4) * 1000;
int readTimeout = args.getInt(5) * 1000;
boolean followRedirect = args.getBoolean(6);
String responseType = args.getString(7);
Integer reqId = args.getInt(8);

Integer reqId = args.getInt(7);
CordovaObservableCallbackContext observableCallbackContext = new CordovaObservableCallbackContext(callbackContext, reqId);

CordovaHttpUpload upload = new CordovaHttpUpload(url, headers, filePaths, uploadNames, timeout, followRedirect,
CordovaHttpUpload upload = new CordovaHttpUpload(url, headers, filePaths, uploadNames, connectTimeout, readTimeout, followRedirect,
responseType, this.tlsConfiguration, this.cordova.getActivity().getApplicationContext(), observableCallbackContext);

startRequest(reqId, observableCallbackContext, upload);
Expand All @@ -162,14 +165,15 @@ private boolean downloadFile(final JSONArray args, final CallbackContext callbac
String url = args.getString(0);
JSONObject headers = args.getJSONObject(1);
String filePath = args.getString(2);
int timeout = args.getInt(3) * 1000;
boolean followRedirect = args.getBoolean(4);
int connectTimeout = args.getInt(3) * 1000;
int readTimeout = args.getInt(4) * 1000;
boolean followRedirect = args.getBoolean(5);
Integer reqId = args.getInt(6);

Integer reqId = args.getInt(5);
CordovaObservableCallbackContext observableCallbackContext = new CordovaObservableCallbackContext(callbackContext, reqId);

CordovaHttpDownload download = new CordovaHttpDownload(url, headers, filePath, timeout, followRedirect,
this.tlsConfiguration, observableCallbackContext);
CordovaHttpDownload download = new CordovaHttpDownload(url, headers, filePath, connectTimeout, readTimeout,
followRedirect, this.tlsConfiguration, observableCallbackContext);

startRequest(reqId, observableCallbackContext, download);

Expand Down

0 comments on commit 1bafe6c

Please sign in to comment.