Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: auth manager: manage empty body and undefined Content-Type on re…
Browse files Browse the repository at this point in the history
…quest
JPPortier committed Nov 24, 2023
1 parent 0e0d9f7 commit 56f1cdf
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import com.sinch.sdk.core.exceptions.ApiException;
import com.sinch.sdk.core.http.AuthManager;
import com.sinch.sdk.core.utils.Pair;
import com.sinch.sdk.core.utils.StringUtil;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
@@ -63,7 +64,9 @@ public Collection<Pair<String, String>> getAuthorizationHeaders(
}

private String getBodyMD5Hash(String body) {

if (StringUtil.isEmpty(body)) {
return "";
}
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(body.getBytes(StandardCharsets.UTF_8));
@@ -80,7 +83,7 @@ private String getSignature(
"\n",
method,
bodyMD5Hash,
httpContentType,
null != httpContentType ? httpContentType : "",
XTIMESTAMP_HEADER + ":" + timestamp.toString(),
path);
}

0 comments on commit 56f1cdf

Please sign in to comment.