Skip to content

Commit

Permalink
Update ConnectionProcessor.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtursKadikis authored Jan 22, 2024
1 parent 1306f07 commit d33c5f3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions sdk/src/main/java/ly/count/android/sdk/ConnectionProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ private enum RequestResult {
}

// determine whether or not request has a binary image file, if it has request will be sent as POST request
boolean hasPicturePath = hasPicturePath(requestData);
boolean hasPicturePath = requestData.contains(ModuleUserProfile.PICTURE_PATH_KEY);
boolean usingHttpPost = (requestData.contains("&crash=") || requestData.length() >= 2048 || requestInfoProvider_.isHttpPostForced()) || hasPicturePath;

long approximateDateSize = 0L;
String urlStr = serverURL_ + urlEndpoint;
approximateDateSize += urlStr.length();


if (usingHttpPost && !hasPicturePath) {
// for binary images, checksum will be calculated without url encoded value of the requestData
// because they sent as form-data and server calculates it that way
requestData = addChecksum(requestData, requestData);
approximateDateSize += requestData.length(); // add request data to the estimated data size
} else {
urlStr += "?" + requestData;
urlStr = addChecksum(urlStr, requestData);
}

approximateDateSize += requestData.length(); // add request data to the estimated data size
approximateDateSize += urlStr.length();

final URL url = new URL(urlStr);
final HttpURLConnection conn;
Expand Down Expand Up @@ -202,10 +202,6 @@ private enum RequestResult {
return conn;
}

boolean hasPicturePath(String requestData) {
return requestData.contains(ModuleUserProfile.PICTURE_PATH_KEY);
}

String addChecksum(String gonnaAdd, String gonnaCalculate) {
String checksum = UtilsNetworking.sha256Hash(gonnaCalculate + requestInfoProvider_.getRequestSalt());
gonnaAdd += "&checksum256=" + checksum;
Expand Down

0 comments on commit d33c5f3

Please sign in to comment.