@capacitor/ios
Advanced tools
Comparing version 6.0.0-nightly-20231208T150452.0 to 6.0.0-nightly-20231211T150450.0
@@ -67,4 +67,48 @@ | ||
}; | ||
const convertBody = async (body) => { | ||
if (body instanceof FormData) { | ||
const convertBody = async (body, contentType) => { | ||
if (body instanceof ReadableStream) { | ||
const reader = body.getReader(); | ||
const chunks = []; | ||
while (true) { | ||
const { done, value } = await reader.read(); | ||
if (done) | ||
break; | ||
chunks.push(value); | ||
} | ||
const concatenated = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0)); | ||
let position = 0; | ||
for (const chunk of chunks) { | ||
concatenated.set(chunk, position); | ||
position += chunk.length; | ||
} | ||
let data = new TextDecoder().decode(concatenated); | ||
let type; | ||
if (contentType === 'application/json') { | ||
try { | ||
data = JSON.parse(data); | ||
} | ||
catch (ignored) { | ||
// ignore | ||
} | ||
type = 'json'; | ||
} | ||
else if (contentType === 'multipart/form-data') { | ||
type = 'formData'; | ||
} | ||
else if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image')) { | ||
type = 'image'; | ||
} | ||
else if (contentType === 'application/octet-stream') { | ||
type = 'binary'; | ||
} | ||
else { | ||
type = 'text'; | ||
} | ||
return { | ||
data, | ||
type, | ||
headers: { 'Content-Type': contentType || 'application/octet-stream' }, | ||
}; | ||
} | ||
else if (body instanceof FormData) { | ||
const formData = await convertFormData(body); | ||
@@ -436,4 +480,4 @@ const boundary = `${Date.now()}`; | ||
const { body, method } = request; | ||
const { data: requestData, type, headers, } = await convertBody(body || undefined); | ||
const optionHeaders = Object.fromEntries(request.headers.entries()); | ||
const { data: requestData, type, headers, } = await convertBody((options === null || options === void 0 ? void 0 : options.body) || body || undefined, optionHeaders['Content-Type'] || optionHeaders['content-type']); | ||
const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', { | ||
@@ -440,0 +484,0 @@ url: request.url, |
{ | ||
"name": "@capacitor/ios", | ||
"version": "6.0.0-nightly-20231208T150452.0", | ||
"version": "6.0.0-nightly-20231211T150450.0", | ||
"description": "Capacitor: Cross-platform apps with JavaScript and the web", | ||
@@ -29,3 +29,3 @@ "homepage": "https://capacitorjs.com", | ||
"peerDependencies": { | ||
"@capacitor/core": "^6.0.0-nightly-20231208T150452.0" | ||
"@capacitor/core": "^6.0.0-nightly-20231211T150450.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
326402
966