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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.23.1",
3
+ "version": "1.23.2",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
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 > -1) {
299
- if (boundaryIndex > 0) {
300
- if (options.useMemory) {
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
- if (isLastBoundary) {
308
- combined = combined.slice(boundaryIndex + boundary.length + 2);
309
- done = true;
310
- break;
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
- // create new part
314
- const bodyFile = tempFilename();
315
- activePart = {
316
- headers: {},
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
@@ -98,7 +98,9 @@ class WebServer {
98
98
 
99
99
  res.on("finish", () => {
100
100
  handled = true;
101
- currentResolve();
101
+ if (currentResolve) {
102
+ currentResolve();
103
+ }
102
104
  });
103
105
 
104
106
  let router = routers.shift();
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
- try {
12
- const parts = await parseMultipart(req, { useMemory: false });
11
+ const parts = await parseMultipart(req, { useMemory: false });
13
12
 
14
- for (const part of parts) {
15
- console.debug(part?.body);
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
- "GET /test"(req, res) {
25
- res.send("Hello World - /test");
17
+ res.send("OK");
26
18
  }
27
19
 
28
20
  }
File without changes