koa-files 3.0.5 → 3.0.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.
- package/cjs/Service.cjs +35 -35
- package/cjs/index.cjs +3 -3
- package/cjs/utils/fs.cjs +1 -1
- package/cjs/utils/hash.cjs +1 -1
- package/cjs/utils/http.cjs +5 -5
- package/cjs/utils/path.cjs +1 -1
- package/esm/Service.js +35 -35
- package/esm/index.js +3 -3
- package/esm/utils/fs.js +1 -1
- package/esm/utils/hash.js +1 -1
- package/esm/utils/http.js +5 -5
- package/esm/utils/path.js +1 -1
- package/package.json +5 -5
- package/types/Service.d.ts +20 -20
- package/types/utils/http.d.ts +4 -4
package/cjs/Service.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -42,8 +42,8 @@ class Service {
|
|
|
42
42
|
/**
|
|
43
43
|
* @constructor
|
|
44
44
|
* @description Create file service.
|
|
45
|
-
* @param root
|
|
46
|
-
* @param options
|
|
45
|
+
* @param root The file service root.
|
|
46
|
+
* @param options The file service options.
|
|
47
47
|
*/
|
|
48
48
|
constructor(root, options) {
|
|
49
49
|
this.options = options;
|
|
@@ -53,7 +53,7 @@ class Service {
|
|
|
53
53
|
* @private
|
|
54
54
|
* @method isIgnore
|
|
55
55
|
* @description Check if path is ignore.
|
|
56
|
-
* @param path
|
|
56
|
+
* @param path The path to check.
|
|
57
57
|
*/
|
|
58
58
|
isIgnore(path) {
|
|
59
59
|
const { ignore } = this.options;
|
|
@@ -62,10 +62,10 @@ class Service {
|
|
|
62
62
|
/**
|
|
63
63
|
* @private
|
|
64
64
|
* @method setupHeaders
|
|
65
|
-
* @description Setup headers
|
|
66
|
-
* @param context
|
|
67
|
-
* @param path
|
|
68
|
-
* @param stats
|
|
65
|
+
* @description Setup headers.
|
|
66
|
+
* @param context The koa context.
|
|
67
|
+
* @param path The file path.
|
|
68
|
+
* @param stats The file stats.
|
|
69
69
|
*/
|
|
70
70
|
setupHeaders(context, path, stats) {
|
|
71
71
|
const { options } = this;
|
|
@@ -111,14 +111,14 @@ class Service {
|
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* @private
|
|
114
|
-
* @method
|
|
115
|
-
* @description
|
|
116
|
-
* @param stream Destination stream.
|
|
114
|
+
* @method read
|
|
115
|
+
* @description Read file with range.
|
|
117
116
|
* @param path The file path to read.
|
|
118
117
|
* @param range The range to read.
|
|
119
|
-
* @param
|
|
118
|
+
* @param stream The destination stream.
|
|
119
|
+
* @param end The end flag after pipe to stream.
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
read(path, range, stream, end) {
|
|
122
122
|
const { fs } = this.options;
|
|
123
123
|
return new Promise(resolve => {
|
|
124
124
|
// Range prefix and suffix.
|
|
@@ -166,24 +166,18 @@ class Service {
|
|
|
166
166
|
/**
|
|
167
167
|
* @private
|
|
168
168
|
* @method send
|
|
169
|
-
* @description Send file.
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
169
|
+
* @description Send file with ranges.
|
|
170
|
+
* @param path The file path to send.
|
|
171
|
+
* @param ranges The ranges to send.
|
|
172
|
+
* @param stream The destination stream.
|
|
173
173
|
*/
|
|
174
|
-
async send(
|
|
175
|
-
// Set stream body, highWaterMark 64kb.
|
|
176
|
-
const stream$1 = new stream.PassThrough({
|
|
177
|
-
highWaterMark: 65536
|
|
178
|
-
});
|
|
179
|
-
// Set response body.
|
|
180
|
-
context.body = stream$1;
|
|
174
|
+
async send(path, ranges, stream) {
|
|
181
175
|
// Ranges length.
|
|
182
176
|
let { length } = ranges;
|
|
183
177
|
// Write ranges to stream.
|
|
184
178
|
for (const range of ranges) {
|
|
185
179
|
// Write range.
|
|
186
|
-
const passed = await this.
|
|
180
|
+
const passed = await this.read(path, range, stream, --length === 0);
|
|
187
181
|
// If not passed, break.
|
|
188
182
|
if (!passed) {
|
|
189
183
|
break;
|
|
@@ -192,23 +186,23 @@ class Service {
|
|
|
192
186
|
}
|
|
193
187
|
/**
|
|
194
188
|
* @public
|
|
195
|
-
* @method
|
|
196
|
-
* @description
|
|
197
|
-
* @param context
|
|
189
|
+
* @method respond
|
|
190
|
+
* @description Respond file.
|
|
191
|
+
* @param context The koa context.
|
|
198
192
|
*/
|
|
199
|
-
async
|
|
193
|
+
async respond(context) {
|
|
200
194
|
const { root } = this;
|
|
201
195
|
// Only support GET and HEAD (405).
|
|
202
196
|
if (context.method !== 'GET' && context.method !== 'HEAD') {
|
|
203
197
|
return false;
|
|
204
198
|
}
|
|
205
|
-
// Get
|
|
199
|
+
// Get pathname of file.
|
|
206
200
|
const pathname = http.decodeURI(context.path);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (path$2 === -1 || path$2.includes('\0')) {
|
|
201
|
+
// Pathname decode failed or includes null byte(s).
|
|
202
|
+
if (pathname === -1 || pathname.includes('\0')) {
|
|
210
203
|
return context.throw(400);
|
|
211
204
|
}
|
|
205
|
+
const path$2 = path.unixify(path$1.join(root, pathname));
|
|
212
206
|
// Malicious path (403).
|
|
213
207
|
if (path.isOutRoot(path$2, root)) {
|
|
214
208
|
return false;
|
|
@@ -270,8 +264,14 @@ class Service {
|
|
|
270
264
|
if (ranges === -2) {
|
|
271
265
|
return context.throw(400);
|
|
272
266
|
}
|
|
273
|
-
//
|
|
274
|
-
|
|
267
|
+
// Set stream body, highWaterMark 64kb.
|
|
268
|
+
const stream$1 = new stream.PassThrough({
|
|
269
|
+
highWaterMark: 65536
|
|
270
|
+
});
|
|
271
|
+
// Send file with ranges.
|
|
272
|
+
this.send(path$2, ranges, stream$1);
|
|
273
|
+
// Set response body.
|
|
274
|
+
context.body = stream$1;
|
|
275
275
|
// File found.
|
|
276
276
|
return true;
|
|
277
277
|
}
|
package/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -32,11 +32,11 @@ function server(root, options) {
|
|
|
32
32
|
if (config.defer) {
|
|
33
33
|
return async (context, next) => {
|
|
34
34
|
await next();
|
|
35
|
-
await service.
|
|
35
|
+
await service.respond(context);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
return async (context, next) => {
|
|
39
|
-
if (!(await service.
|
|
39
|
+
if (!(await service.respond(context))) {
|
|
40
40
|
await next();
|
|
41
41
|
}
|
|
42
42
|
};
|
package/cjs/utils/fs.cjs
CHANGED
package/cjs/utils/hash.cjs
CHANGED
package/cjs/utils/http.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -108,7 +108,7 @@ function decodeURI(URI) {
|
|
|
108
108
|
/**
|
|
109
109
|
* @function isConditionalGET
|
|
110
110
|
* @description Check if request is conditional GET.
|
|
111
|
-
* @param context
|
|
111
|
+
* @param context The koa context.
|
|
112
112
|
*/
|
|
113
113
|
function isConditionalGET(context) {
|
|
114
114
|
const { request } = context;
|
|
@@ -122,7 +122,7 @@ function isConditionalGET(context) {
|
|
|
122
122
|
/**
|
|
123
123
|
* @function isPreconditionFailure
|
|
124
124
|
* @description Check if request precondition failure.
|
|
125
|
-
* @param context
|
|
125
|
+
* @param context The koa context.
|
|
126
126
|
*/
|
|
127
127
|
function isPreconditionFailure({ request, response }) {
|
|
128
128
|
// If-Match.
|
|
@@ -147,8 +147,8 @@ function isPreconditionFailure({ request, response }) {
|
|
|
147
147
|
/**
|
|
148
148
|
* @function parseRanges
|
|
149
149
|
* @description Parse ranges.
|
|
150
|
-
* @param context
|
|
151
|
-
* @param stats
|
|
150
|
+
* @param context The koa context.
|
|
151
|
+
* @param stats The file stats.
|
|
152
152
|
*/
|
|
153
153
|
function parseRanges(context, stats) {
|
|
154
154
|
const { size } = stats;
|
package/cjs/utils/path.cjs
CHANGED
package/esm/Service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -33,8 +33,8 @@ class Service {
|
|
|
33
33
|
/**
|
|
34
34
|
* @constructor
|
|
35
35
|
* @description Create file service.
|
|
36
|
-
* @param root
|
|
37
|
-
* @param options
|
|
36
|
+
* @param root The file service root.
|
|
37
|
+
* @param options The file service options.
|
|
38
38
|
*/
|
|
39
39
|
constructor(root, options) {
|
|
40
40
|
this.options = options;
|
|
@@ -44,7 +44,7 @@ class Service {
|
|
|
44
44
|
* @private
|
|
45
45
|
* @method isIgnore
|
|
46
46
|
* @description Check if path is ignore.
|
|
47
|
-
* @param path
|
|
47
|
+
* @param path The path to check.
|
|
48
48
|
*/
|
|
49
49
|
isIgnore(path) {
|
|
50
50
|
const { ignore } = this.options;
|
|
@@ -53,10 +53,10 @@ class Service {
|
|
|
53
53
|
/**
|
|
54
54
|
* @private
|
|
55
55
|
* @method setupHeaders
|
|
56
|
-
* @description Setup headers
|
|
57
|
-
* @param context
|
|
58
|
-
* @param path
|
|
59
|
-
* @param stats
|
|
56
|
+
* @description Setup headers.
|
|
57
|
+
* @param context The koa context.
|
|
58
|
+
* @param path The file path.
|
|
59
|
+
* @param stats The file stats.
|
|
60
60
|
*/
|
|
61
61
|
setupHeaders(context, path, stats) {
|
|
62
62
|
const { options } = this;
|
|
@@ -102,14 +102,14 @@ class Service {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* @private
|
|
105
|
-
* @method
|
|
106
|
-
* @description
|
|
107
|
-
* @param stream Destination stream.
|
|
105
|
+
* @method read
|
|
106
|
+
* @description Read file with range.
|
|
108
107
|
* @param path The file path to read.
|
|
109
108
|
* @param range The range to read.
|
|
110
|
-
* @param
|
|
109
|
+
* @param stream The destination stream.
|
|
110
|
+
* @param end The end flag after pipe to stream.
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
read(path, range, stream, end) {
|
|
113
113
|
const { fs } = this.options;
|
|
114
114
|
return new Promise(resolve => {
|
|
115
115
|
// Range prefix and suffix.
|
|
@@ -157,24 +157,18 @@ class Service {
|
|
|
157
157
|
/**
|
|
158
158
|
* @private
|
|
159
159
|
* @method send
|
|
160
|
-
* @description Send file.
|
|
161
|
-
* @param
|
|
162
|
-
* @param
|
|
163
|
-
* @param
|
|
160
|
+
* @description Send file with ranges.
|
|
161
|
+
* @param path The file path to send.
|
|
162
|
+
* @param ranges The ranges to send.
|
|
163
|
+
* @param stream The destination stream.
|
|
164
164
|
*/
|
|
165
|
-
async send(
|
|
166
|
-
// Set stream body, highWaterMark 64kb.
|
|
167
|
-
const stream = new PassThrough({
|
|
168
|
-
highWaterMark: 65536
|
|
169
|
-
});
|
|
170
|
-
// Set response body.
|
|
171
|
-
context.body = stream;
|
|
165
|
+
async send(path, ranges, stream) {
|
|
172
166
|
// Ranges length.
|
|
173
167
|
let { length } = ranges;
|
|
174
168
|
// Write ranges to stream.
|
|
175
169
|
for (const range of ranges) {
|
|
176
170
|
// Write range.
|
|
177
|
-
const passed = await this.
|
|
171
|
+
const passed = await this.read(path, range, stream, --length === 0);
|
|
178
172
|
// If not passed, break.
|
|
179
173
|
if (!passed) {
|
|
180
174
|
break;
|
|
@@ -183,23 +177,23 @@ class Service {
|
|
|
183
177
|
}
|
|
184
178
|
/**
|
|
185
179
|
* @public
|
|
186
|
-
* @method
|
|
187
|
-
* @description
|
|
188
|
-
* @param context
|
|
180
|
+
* @method respond
|
|
181
|
+
* @description Respond file.
|
|
182
|
+
* @param context The koa context.
|
|
189
183
|
*/
|
|
190
|
-
async
|
|
184
|
+
async respond(context) {
|
|
191
185
|
const { root } = this;
|
|
192
186
|
// Only support GET and HEAD (405).
|
|
193
187
|
if (context.method !== 'GET' && context.method !== 'HEAD') {
|
|
194
188
|
return false;
|
|
195
189
|
}
|
|
196
|
-
// Get
|
|
190
|
+
// Get pathname of file.
|
|
197
191
|
const pathname = decodeURI(context.path);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (path === -1 || path.includes('\0')) {
|
|
192
|
+
// Pathname decode failed or includes null byte(s).
|
|
193
|
+
if (pathname === -1 || pathname.includes('\0')) {
|
|
201
194
|
return context.throw(400);
|
|
202
195
|
}
|
|
196
|
+
const path = unixify(join(root, pathname));
|
|
203
197
|
// Malicious path (403).
|
|
204
198
|
if (isOutRoot(path, root)) {
|
|
205
199
|
return false;
|
|
@@ -261,8 +255,14 @@ class Service {
|
|
|
261
255
|
if (ranges === -2) {
|
|
262
256
|
return context.throw(400);
|
|
263
257
|
}
|
|
264
|
-
//
|
|
265
|
-
|
|
258
|
+
// Set stream body, highWaterMark 64kb.
|
|
259
|
+
const stream = new PassThrough({
|
|
260
|
+
highWaterMark: 65536
|
|
261
|
+
});
|
|
262
|
+
// Send file with ranges.
|
|
263
|
+
this.send(path, ranges, stream);
|
|
264
|
+
// Set response body.
|
|
265
|
+
context.body = stream;
|
|
266
266
|
// File found.
|
|
267
267
|
return true;
|
|
268
268
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -24,11 +24,11 @@ function server(root, options) {
|
|
|
24
24
|
if (config.defer) {
|
|
25
25
|
return async (context, next) => {
|
|
26
26
|
await next();
|
|
27
|
-
await service.
|
|
27
|
+
await service.respond(context);
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
return async (context, next) => {
|
|
31
|
-
if (!(await service.
|
|
31
|
+
if (!(await service.respond(context))) {
|
|
32
32
|
await next();
|
|
33
33
|
}
|
|
34
34
|
};
|
package/esm/utils/fs.js
CHANGED
package/esm/utils/hash.js
CHANGED
package/esm/utils/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.7
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -100,7 +100,7 @@ function decodeURI(URI) {
|
|
|
100
100
|
/**
|
|
101
101
|
* @function isConditionalGET
|
|
102
102
|
* @description Check if request is conditional GET.
|
|
103
|
-
* @param context
|
|
103
|
+
* @param context The koa context.
|
|
104
104
|
*/
|
|
105
105
|
function isConditionalGET(context) {
|
|
106
106
|
const { request } = context;
|
|
@@ -114,7 +114,7 @@ function isConditionalGET(context) {
|
|
|
114
114
|
/**
|
|
115
115
|
* @function isPreconditionFailure
|
|
116
116
|
* @description Check if request precondition failure.
|
|
117
|
-
* @param context
|
|
117
|
+
* @param context The koa context.
|
|
118
118
|
*/
|
|
119
119
|
function isPreconditionFailure({ request, response }) {
|
|
120
120
|
// If-Match.
|
|
@@ -139,8 +139,8 @@ function isPreconditionFailure({ request, response }) {
|
|
|
139
139
|
/**
|
|
140
140
|
* @function parseRanges
|
|
141
141
|
* @description Parse ranges.
|
|
142
|
-
* @param context
|
|
143
|
-
* @param stats
|
|
142
|
+
* @param context The koa context.
|
|
143
|
+
* @param stats The file stats.
|
|
144
144
|
*/
|
|
145
145
|
function parseRanges(context, stats) {
|
|
146
146
|
const { size } = stats;
|
package/esm/utils/path.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koa-files",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "A static files serving middleware for koa.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "cjs/index.cjs",
|
|
@@ -60,18 +60,18 @@
|
|
|
60
60
|
"tslib": "^2.7.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@rollup/plugin-typescript": "^
|
|
63
|
+
"@rollup/plugin-typescript": "^12.1.0",
|
|
64
64
|
"@types/destroy": "^1.0.3",
|
|
65
65
|
"@types/etag": "^1.8.3",
|
|
66
66
|
"@types/koa": "^2.15.0",
|
|
67
67
|
"@types/range-parser": "^1.2.7",
|
|
68
68
|
"koa": "^2.15.3",
|
|
69
|
-
"magic-string": "^0.30.
|
|
69
|
+
"magic-string": "^0.30.12",
|
|
70
70
|
"prettier": "^3.3.3",
|
|
71
71
|
"rimraf": "^6.0.1",
|
|
72
|
-
"rollup": "^4.
|
|
72
|
+
"rollup": "^4.24.0",
|
|
73
73
|
"tsc-alias": "^1.8.10",
|
|
74
|
-
"typescript": "^5.6.
|
|
74
|
+
"typescript": "^5.6.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"koa": "^2.0.0"
|
package/types/Service.d.ts
CHANGED
|
@@ -30,51 +30,51 @@ export default class Service {
|
|
|
30
30
|
/**
|
|
31
31
|
* @constructor
|
|
32
32
|
* @description Create file service.
|
|
33
|
-
* @param root
|
|
34
|
-
* @param options
|
|
33
|
+
* @param root The file service root.
|
|
34
|
+
* @param options The file service options.
|
|
35
35
|
*/
|
|
36
36
|
constructor(root: string, options: Options);
|
|
37
37
|
/**
|
|
38
38
|
* @private
|
|
39
39
|
* @method isIgnore
|
|
40
40
|
* @description Check if path is ignore.
|
|
41
|
-
* @param path
|
|
41
|
+
* @param path The path to check.
|
|
42
42
|
*/
|
|
43
43
|
private isIgnore;
|
|
44
44
|
/**
|
|
45
45
|
* @private
|
|
46
46
|
* @method setupHeaders
|
|
47
|
-
* @description Setup headers
|
|
48
|
-
* @param context
|
|
49
|
-
* @param path
|
|
50
|
-
* @param stats
|
|
47
|
+
* @description Setup headers.
|
|
48
|
+
* @param context The koa context.
|
|
49
|
+
* @param path The file path.
|
|
50
|
+
* @param stats The file stats.
|
|
51
51
|
*/
|
|
52
52
|
private setupHeaders;
|
|
53
53
|
/**
|
|
54
54
|
* @private
|
|
55
|
-
* @method
|
|
56
|
-
* @description
|
|
57
|
-
* @param stream Destination stream.
|
|
55
|
+
* @method read
|
|
56
|
+
* @description Read file with range.
|
|
58
57
|
* @param path The file path to read.
|
|
59
58
|
* @param range The range to read.
|
|
60
|
-
* @param
|
|
59
|
+
* @param stream The destination stream.
|
|
60
|
+
* @param end The end flag after pipe to stream.
|
|
61
61
|
*/
|
|
62
|
-
private
|
|
62
|
+
private read;
|
|
63
63
|
/**
|
|
64
64
|
* @private
|
|
65
65
|
* @method send
|
|
66
|
-
* @description Send file.
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
66
|
+
* @description Send file with ranges.
|
|
67
|
+
* @param path The file path to send.
|
|
68
|
+
* @param ranges The ranges to send.
|
|
69
|
+
* @param stream The destination stream.
|
|
70
70
|
*/
|
|
71
71
|
private send;
|
|
72
72
|
/**
|
|
73
73
|
* @public
|
|
74
|
-
* @method
|
|
75
|
-
* @description
|
|
76
|
-
* @param context
|
|
74
|
+
* @method respond
|
|
75
|
+
* @description Respond file.
|
|
76
|
+
* @param context The koa context.
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
respond(context: Context): Promise<boolean>;
|
|
79
79
|
}
|
|
80
80
|
export {};
|
package/types/utils/http.d.ts
CHANGED
|
@@ -19,20 +19,20 @@ export declare function decodeURI(URI: string): string | -1;
|
|
|
19
19
|
/**
|
|
20
20
|
* @function isConditionalGET
|
|
21
21
|
* @description Check if request is conditional GET.
|
|
22
|
-
* @param context
|
|
22
|
+
* @param context The koa context.
|
|
23
23
|
*/
|
|
24
24
|
export declare function isConditionalGET(context: Context): boolean;
|
|
25
25
|
/**
|
|
26
26
|
* @function isPreconditionFailure
|
|
27
27
|
* @description Check if request precondition failure.
|
|
28
|
-
* @param context
|
|
28
|
+
* @param context The koa context.
|
|
29
29
|
*/
|
|
30
30
|
export declare function isPreconditionFailure({ request, response }: Context): boolean;
|
|
31
31
|
/**
|
|
32
32
|
* @function parseRanges
|
|
33
33
|
* @description Parse ranges.
|
|
34
|
-
* @param context
|
|
35
|
-
* @param stats
|
|
34
|
+
* @param context The koa context.
|
|
35
|
+
* @param stats The file stats.
|
|
36
36
|
*/
|
|
37
37
|
export declare function parseRanges(context: Context, stats: Stats): Ranges;
|
|
38
38
|
export {};
|