Skip to content

Commit d9a902b

Browse files
committed
Set English locale for toLowerCase methods to fix joltup#573 dotless i problem
1 parent a0b26a2 commit d9a902b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

android/.settings/org.eclipse.buildship.core.prefs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
55
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
8-
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
8+
java.home=/usr/lib/jvm/java-11-openjdk-amd64
99
jvm.arguments=
1010
offline.mode=false
1111
override.workspace.settings=true

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.ArrayList;
5050
import java.util.Arrays;
5151
import java.util.List;
52+
import java.util.Locale;
5253
import java.util.HashMap;
5354

5455
import java.util.concurrent.TimeUnit;
@@ -115,6 +116,7 @@ enum ResponseFormat {
115116
boolean timeout = false;
116117
ArrayList<String> redirects = new ArrayList<>();
117118
OkHttpClient client;
119+
Locale httpHeaderLocale = Locale.ENGLISH;
118120

119121
public RNFetchBlobReq(ReadableMap options, String taskId, String method, String url, ReadableMap headers, String body, ReadableArray arrayBody, OkHttpClient client, final Callback callback) {
120122
this.method = method.toUpperCase();
@@ -300,14 +302,14 @@ else if (value.equalsIgnoreCase("utf8"))
300302
responseFormat = ResponseFormat.UTF8;
301303
}
302304
else {
303-
builder.header(key.toLowerCase(), value);
304-
mheaders.put(key.toLowerCase(), value);
305+
builder.header(key.toLowerCase(httpHeaderLocale), value);
306+
mheaders.put(key.toLowerCase(httpHeaderLocale), value);
305307
}
306308
}
307309
}
308310

309311
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch")) {
310-
String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase();
312+
String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase(httpHeaderLocale);
311313

312314
if(rawRequestBodyArray != null) {
313315
requestType = RequestType.Form;
@@ -323,7 +325,7 @@ else if(cType.isEmpty()) {
323325
|| rawRequestBody.startsWith(RNFetchBlobConst.CONTENT_PREFIX)) {
324326
requestType = RequestType.SingleFile;
325327
}
326-
else if (cType.toLowerCase().contains(";base64") || cType.toLowerCase().startsWith("application/octet")) {
328+
else if (cType.toLowerCase().contains(";base64") || cType.toLowerCase(httpHeaderLocale).startsWith("application/octet")) {
327329
cType = cType.replace(";base64","").replace(";BASE64","");
328330
if(mheaders.containsKey("content-type"))
329331
mheaders.put("content-type", cType);
@@ -717,7 +719,7 @@ private boolean isBlobResponse(Response resp) {
717719
boolean isCustomBinary = false;
718720
if(options.binaryContentTypes != null) {
719721
for(int i = 0; i< options.binaryContentTypes.size();i++) {
720-
if(ctype.toLowerCase().contains(options.binaryContentTypes.getString(i).toLowerCase())) {
722+
if(ctype.toLowerCase(httpHeaderLocale).contains(options.binaryContentTypes.getString(i).toLowerCase())) {
721723
isCustomBinary = true;
722724
break;
723725
}
@@ -729,13 +731,13 @@ private boolean isBlobResponse(Response resp) {
729731
private String getHeaderIgnoreCases(Headers headers, String field) {
730732
String val = headers.get(field);
731733
if(val != null) return val;
732-
return headers.get(field.toLowerCase()) == null ? "" : headers.get(field.toLowerCase());
734+
return headers.get(field.toLowerCase(httpHeaderLocale)) == null ? "" : headers.get(field.toLowerCase(Locale.English));
733735
}
734736

735737
private String getHeaderIgnoreCases(HashMap<String,String> headers, String field) {
736738
String val = headers.get(field);
737739
if(val != null) return val;
738-
String lowerCasedValue = headers.get(field.toLowerCase());
740+
String lowerCasedValue = headers.get(field.toLowerCase(httpHeaderLocale));
739741
return lowerCasedValue == null ? "" : lowerCasedValue;
740742
}
741743

0 commit comments

Comments
 (0)