@capacitor/android 5.7.5 → 5.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,22 +65,29 @@ var nativeBridge = (function (exports) {
|
|
|
65
65
|
return newFormData;
|
|
66
66
|
};
|
|
67
67
|
const convertBody = async (body, contentType) => {
|
|
68
|
-
if (body instanceof ReadableStream) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
if (body instanceof ReadableStream || body instanceof Uint8Array) {
|
|
69
|
+
let encodedData;
|
|
70
|
+
if (body instanceof ReadableStream) {
|
|
71
|
+
const reader = body.getReader();
|
|
72
|
+
const chunks = [];
|
|
73
|
+
while (true) {
|
|
74
|
+
const { done, value } = await reader.read();
|
|
75
|
+
if (done)
|
|
76
|
+
break;
|
|
77
|
+
chunks.push(value);
|
|
78
|
+
}
|
|
79
|
+
const concatenated = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
|
80
|
+
let position = 0;
|
|
81
|
+
for (const chunk of chunks) {
|
|
82
|
+
concatenated.set(chunk, position);
|
|
83
|
+
position += chunk.length;
|
|
84
|
+
}
|
|
85
|
+
encodedData = concatenated;
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
for (const chunk of chunks) {
|
|
80
|
-
concatenated.set(chunk, position);
|
|
81
|
-
position += chunk.length;
|
|
87
|
+
else {
|
|
88
|
+
encodedData = body;
|
|
82
89
|
}
|
|
83
|
-
let data = new TextDecoder().decode(
|
|
90
|
+
let data = new TextDecoder().decode(encodedData);
|
|
84
91
|
let type;
|
|
85
92
|
if (contentType === 'application/json') {
|
|
86
93
|
try {
|
|
@@ -569,20 +576,7 @@ var nativeBridge = (function (exports) {
|
|
|
569
576
|
value: xhr.method,
|
|
570
577
|
writable: true,
|
|
571
578
|
},
|
|
572
|
-
readyState: {
|
|
573
|
-
get: function () {
|
|
574
|
-
var _a;
|
|
575
|
-
return (_a = this._readyState) !== null && _a !== void 0 ? _a : 0;
|
|
576
|
-
},
|
|
577
|
-
set: function (val) {
|
|
578
|
-
this._readyState = val;
|
|
579
|
-
setTimeout(() => {
|
|
580
|
-
this.dispatchEvent(new Event('readystatechange'));
|
|
581
|
-
});
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
579
|
});
|
|
585
|
-
xhr.readyState = 0;
|
|
586
580
|
const prototype = win.CapacitorWebXMLHttpRequest.prototype;
|
|
587
581
|
const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' &&
|
|
588
582
|
ProgressEvent.prototype instanceof Event;
|
|
@@ -612,6 +606,20 @@ var nativeBridge = (function (exports) {
|
|
|
612
606
|
this._url = createProxyUrl(this._url, win);
|
|
613
607
|
return win.CapacitorWebXMLHttpRequest.open.call(this, method, this._url);
|
|
614
608
|
}
|
|
609
|
+
Object.defineProperties(this, {
|
|
610
|
+
readyState: {
|
|
611
|
+
get: function () {
|
|
612
|
+
var _a;
|
|
613
|
+
return (_a = this._readyState) !== null && _a !== void 0 ? _a : 0;
|
|
614
|
+
},
|
|
615
|
+
set: function (val) {
|
|
616
|
+
this._readyState = val;
|
|
617
|
+
setTimeout(() => {
|
|
618
|
+
this.dispatchEvent(new Event('readystatechange'));
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
});
|
|
615
623
|
setTimeout(() => {
|
|
616
624
|
this.dispatchEvent(new Event('loadstart'));
|
|
617
625
|
});
|
package/capacitor/src/main/java/com/getcapacitor/plugin/util/CapacitorHttpUrlConnection.java
CHANGED
|
@@ -275,7 +275,7 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
|
|
|
275
275
|
if (type.equals("string")) {
|
|
276
276
|
os.writeBytes(twoHyphens + boundary + lineEnd);
|
|
277
277
|
os.writeBytes("Content-Disposition: form-data; name=\"" + key + "\"" + lineEnd + lineEnd);
|
|
278
|
-
os.
|
|
278
|
+
os.write(value.getBytes(StandardCharsets.UTF_8));
|
|
279
279
|
os.writeBytes(lineEnd);
|
|
280
280
|
} else if (type.equals("base64File")) {
|
|
281
281
|
String fileName = entry.getString("fileName");
|
|
@@ -289,6 +289,8 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
|
|
|
289
289
|
|
|
290
290
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
291
291
|
os.write(Base64.getDecoder().decode(value));
|
|
292
|
+
} else {
|
|
293
|
+
os.write(android.util.Base64.decode(value, android.util.Base64.DEFAULT));
|
|
292
294
|
}
|
|
293
295
|
|
|
294
296
|
os.writeBytes(lineEnd);
|
package/package.json
CHANGED