geonix 1.23.1 → 1.23.2
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.
- package/package.json +1 -1
- package/src/Util.js +34 -32
- package/src/WebServer.js +3 -1
- package/test/gateway.js +4 -12
- package/test/big_upload.js +0 -0
package/package.json
CHANGED
package/src/Util.js
CHANGED
|
@@ -295,43 +295,45 @@ export async function parseMultipart(req, _options) {
|
|
|
295
295
|
const boundaryIndex = combined.indexOf(boundary);
|
|
296
296
|
const isLastBoundary = combined[boundaryIndex + boundary.length] === 45 && combined[boundaryIndex + boundary.length + 1] === 45;
|
|
297
297
|
|
|
298
|
-
if (boundaryIndex
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
activePart.body.push(combined.slice(0, boundaryIndex));
|
|
302
|
-
} else {
|
|
303
|
-
activePart.body.write(combined.slice(0, boundaryIndex));
|
|
304
|
-
}
|
|
305
|
-
}
|
|
298
|
+
if (boundaryIndex === -1) {
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
306
301
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
302
|
+
if (boundaryIndex > 0) {
|
|
303
|
+
if (options.useMemory) {
|
|
304
|
+
activePart.body.push(combined.slice(0, boundaryIndex));
|
|
305
|
+
} else {
|
|
306
|
+
activePart.body.write(combined.slice(0, boundaryIndex));
|
|
311
307
|
}
|
|
308
|
+
}
|
|
312
309
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
bodyFile: options.useMemory ? undefined : bodyFile,
|
|
318
|
-
body: options.useMemory ? [] : createWriteStream(bodyFile, { flags: "wx" })
|
|
319
|
-
};
|
|
320
|
-
parts.push(activePart);
|
|
321
|
-
|
|
322
|
-
const endOfHeaders = combined.indexOf(END_OF_HEADERS, boundaryIndex);
|
|
323
|
-
activePart.headers = combined
|
|
324
|
-
.slice(boundaryIndex + boundary.length + 2, endOfHeaders).toString()
|
|
325
|
-
.split("\r\n")
|
|
326
|
-
.reduce((acc, val) => {
|
|
327
|
-
const [header, value] = val.split(": ");
|
|
328
|
-
acc[header.toLowerCase()] = value;
|
|
329
|
-
return acc;
|
|
330
|
-
}, {});
|
|
331
|
-
|
|
332
|
-
combined = combined.slice(endOfHeaders + END_OF_HEADERS.length);
|
|
310
|
+
if (isLastBoundary) {
|
|
311
|
+
combined = combined.slice(boundaryIndex + boundary.length + 2);
|
|
312
|
+
done = true;
|
|
313
|
+
break;
|
|
333
314
|
}
|
|
334
315
|
|
|
316
|
+
// create new part
|
|
317
|
+
const bodyFile = tempFilename();
|
|
318
|
+
activePart = {
|
|
319
|
+
headers: {},
|
|
320
|
+
bodyFile: options.useMemory ? undefined : bodyFile,
|
|
321
|
+
body: options.useMemory ? [] : createWriteStream(bodyFile, { flags: "wx" })
|
|
322
|
+
};
|
|
323
|
+
parts.push(activePart);
|
|
324
|
+
|
|
325
|
+
const endOfHeaders = combined.indexOf(END_OF_HEADERS, boundaryIndex);
|
|
326
|
+
activePart.headers = combined
|
|
327
|
+
.slice(boundaryIndex + boundary.length + 2, endOfHeaders).toString()
|
|
328
|
+
.split("\r\n")
|
|
329
|
+
.reduce((acc, val) => {
|
|
330
|
+
const [header, value] = val.split(": ");
|
|
331
|
+
acc[header.toLowerCase()] = value;
|
|
332
|
+
return acc;
|
|
333
|
+
}, {});
|
|
334
|
+
|
|
335
|
+
combined = combined.slice(endOfHeaders + END_OF_HEADERS.length);
|
|
336
|
+
|
|
335
337
|
lastChunk = combined;
|
|
336
338
|
}
|
|
337
339
|
|
package/src/WebServer.js
CHANGED
package/test/gateway.js
CHANGED
|
@@ -8,21 +8,13 @@ class TestService extends Service {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async "POST /upload"(req, res) {
|
|
11
|
-
|
|
12
|
-
const parts = await parseMultipart(req, { useMemory: false });
|
|
11
|
+
const parts = await parseMultipart(req, { useMemory: false });
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
res.send("OK");
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.error(e);
|
|
13
|
+
for (const part of parts) {
|
|
14
|
+
console.log(part.body);
|
|
21
15
|
}
|
|
22
|
-
}
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
res.send("Hello World - /test");
|
|
17
|
+
res.send("OK");
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
}
|
package/test/big_upload.js
DELETED
|
File without changes
|