@opra/http 1.24.2 → 1.24.4
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.
|
@@ -138,7 +138,7 @@ export class HttpOutgoingHost {
|
|
|
138
138
|
this.setHeader('Content-Type', setCharset(ctype || 'txt', encoding));
|
|
139
139
|
}
|
|
140
140
|
// populate Content-Length
|
|
141
|
-
let len
|
|
141
|
+
let len;
|
|
142
142
|
if (chunk !== undefined) {
|
|
143
143
|
if (Buffer.isBuffer(chunk)) {
|
|
144
144
|
// get length of Buffer
|
package/impl/multipart-reader.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { randomFillSync } from 'node:crypto';
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import os from 'node:os';
|
|
4
3
|
import nodePath from 'node:path';
|
|
@@ -7,6 +6,7 @@ import { BadRequestError } from '@opra/common';
|
|
|
7
6
|
import busboy from 'busboy';
|
|
8
7
|
import { EventEmitter } from 'events';
|
|
9
8
|
import fsPromise from 'fs/promises';
|
|
9
|
+
import { uid } from 'uid';
|
|
10
10
|
import { isNotNullish } from 'valgen';
|
|
11
11
|
export class MultipartReader extends EventEmitter {
|
|
12
12
|
context;
|
|
@@ -52,7 +52,7 @@ export class MultipartReader extends EventEmitter {
|
|
|
52
52
|
this.emit('item', item);
|
|
53
53
|
});
|
|
54
54
|
form.on('file', (field, file, info) => {
|
|
55
|
-
const saveTo =
|
|
55
|
+
const saveTo = generateFileName(info, this.tempDirectory);
|
|
56
56
|
file.pipe(fs.createWriteStream(saveTo));
|
|
57
57
|
file.once('end', () => {
|
|
58
58
|
const item = {
|
|
@@ -197,13 +197,18 @@ export class MultipartReader extends EventEmitter {
|
|
|
197
197
|
this._items.forEach(item => {
|
|
198
198
|
if (item.kind !== 'file')
|
|
199
199
|
return;
|
|
200
|
-
promises.push(fsPromise.unlink(item.storedPath));
|
|
200
|
+
promises.push(fsPromise.unlink(item.storedPath).catch(() => { }));
|
|
201
201
|
});
|
|
202
202
|
return Promise.allSettled(promises);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function generateFileName() {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
function generateFileName(info, tempDirectory) {
|
|
206
|
+
let filename;
|
|
207
|
+
let prefix = '';
|
|
208
|
+
while (true) {
|
|
209
|
+
filename = nodePath.posix.join(tempDirectory, info.filename ? prefix + info.filename : 'opra-' + uid(12));
|
|
210
|
+
if (!fs.existsSync(filename))
|
|
211
|
+
return filename;
|
|
212
|
+
prefix = uid(6) + '-';
|
|
213
|
+
}
|
|
209
214
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/http",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.4",
|
|
4
4
|
"description": "Opra Http Server Adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"fresh": "^0.5.2",
|
|
24
24
|
"iconv-lite": "^0.7.2",
|
|
25
25
|
"mime-types": "^3.0.2",
|
|
26
|
-
"node-events-async": "^1.5.
|
|
27
|
-
"power-tasks": "^1.
|
|
26
|
+
"node-events-async": "^1.5.2",
|
|
27
|
+
"power-tasks": "^1.14.2",
|
|
28
28
|
"putil-varhelpers": "^1.7.0",
|
|
29
29
|
"range-parser": "^1.2.1",
|
|
30
30
|
"raw-body": "^3.0.2",
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"super-fast-md5": "^1.0.3",
|
|
33
33
|
"toml": "^3.0.0",
|
|
34
34
|
"tslib": "^2.8.1",
|
|
35
|
+
"uid": "^2.0.2",
|
|
35
36
|
"valgen": "^5.19.5",
|
|
36
37
|
"vary": "^1.1.2",
|
|
37
|
-
"yaml": "^2.8.
|
|
38
|
+
"yaml": "^2.8.3"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@opra/common": "^1.24.
|
|
41
|
-
"@opra/core": "^1.24.
|
|
41
|
+
"@opra/common": "^1.24.4",
|
|
42
|
+
"@opra/core": "^1.24.4"
|
|
42
43
|
},
|
|
43
44
|
"optionalDependencies": {
|
|
44
45
|
"express": "^4.0.0 || ^5.0.0",
|