xshell 1.3.64 → 1.3.66
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/antd.development.js +6855 -6745
- package/antd.development.js.map +1 -1
- package/antd.production.js +1561 -1486
- package/antd.production.js.map +1 -1
- package/apps.d.ts +1 -1
- package/file.d.ts +1 -1
- package/file.js +15 -4
- package/fzip.js +4 -2
- package/git.d.ts +2 -2
- package/package.json +5 -5
- package/react.production.js +23 -23
- package/react.production.js.map +1 -1
- package/server.d.ts +2 -1
- package/server.js +23 -9
package/server.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export declare class Server {
|
|
|
145
145
|
)
|
|
146
146
|
return
|
|
147
147
|
} */
|
|
148
|
-
try_send(ctx: Context, fp: string, { fpd_root, assets_root, sea: _sea, log_404 }?: {
|
|
148
|
+
try_send(ctx: Context, fp: string, { fpd_root, assets_root, sea: _sea, log_404, }?: {
|
|
149
149
|
fpd_root?: string;
|
|
150
150
|
assets_root?: string;
|
|
151
151
|
sea?: boolean;
|
|
@@ -171,6 +171,7 @@ export declare class Server {
|
|
|
171
171
|
sea?: boolean;
|
|
172
172
|
}): Promise<string>;
|
|
173
173
|
set_content_type(response: Koa.Response, fext: string): void;
|
|
174
|
+
set_text(response: Koa.Response, body: string, status?: number): void;
|
|
174
175
|
/** - range: 取值为逗号分割的多个可用端口或端口区间 (不能含有空格,包含区间右值),比如:`8321,8322,8300-8310,11000-11999
|
|
175
176
|
- reverse?: `false` 在 range 内从后往前尝试 */
|
|
176
177
|
static get_available_port(range: string, reverse?: boolean): Promise<number>;
|
package/server.js
CHANGED
|
@@ -13,7 +13,7 @@ import { contentType as get_content_type } from 'mime-types';
|
|
|
13
13
|
// --- my libs
|
|
14
14
|
import { t } from './i18n/instance.js';
|
|
15
15
|
import { request as _request, Remote, get_socket_ip } from './net.js';
|
|
16
|
-
import { inspect, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream, colored, url_width, defer2 } from './utils.js';
|
|
16
|
+
import { inspect, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream, colored, url_width, defer2, nowstr } from './utils.js';
|
|
17
17
|
import { flist, fread, fstat } from './file.js';
|
|
18
18
|
import { exe_nodejs, sea } from './process.js';
|
|
19
19
|
// ------------ my server
|
|
@@ -320,9 +320,7 @@ export class Server {
|
|
|
320
320
|
catch (error) {
|
|
321
321
|
if (error.status !== 404)
|
|
322
322
|
console.error(error);
|
|
323
|
-
response
|
|
324
|
-
response.set('content-type', text_plain);
|
|
325
|
-
response.body = inspect_error(error);
|
|
323
|
+
this.set_text(response, inspect_error(error), error.status || 500);
|
|
326
324
|
}
|
|
327
325
|
}
|
|
328
326
|
/** 解析 req.body to request.body
|
|
@@ -343,8 +341,20 @@ export class Server {
|
|
|
343
341
|
req.body;
|
|
344
342
|
}
|
|
345
343
|
async _router(ctx, next) {
|
|
346
|
-
let { request } = ctx;
|
|
347
|
-
|
|
344
|
+
let { request, response } = ctx;
|
|
345
|
+
let _path;
|
|
346
|
+
try {
|
|
347
|
+
_path = request._path = decodeURIComponent(request.path);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
if (error instanceof URIError) {
|
|
351
|
+
const message = 'url 格式不对';
|
|
352
|
+
this.set_text(response, message, 400);
|
|
353
|
+
console.log(`${nowstr()} ${message}: ${request.path} ${request.ip}/${this.get_client_info(request.headers)}`);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
348
358
|
Object.defineProperty(request, 'path', {
|
|
349
359
|
value: _path,
|
|
350
360
|
configurable: true,
|
|
@@ -631,9 +641,7 @@ export class Server {
|
|
|
631
641
|
else {
|
|
632
642
|
if (this.print.errors)
|
|
633
643
|
console.log(error);
|
|
634
|
-
response
|
|
635
|
-
response.set('content-type', text_plain);
|
|
636
|
-
response.body = inspect_error(error);
|
|
644
|
+
this.set_text(response, inspect_error(error), 500);
|
|
637
645
|
}
|
|
638
646
|
}
|
|
639
647
|
return true;
|
|
@@ -798,6 +806,12 @@ export class Server {
|
|
|
798
806
|
:
|
|
799
807
|
get_content_type(`file.${fext}`) || 'application/octet-stream'));
|
|
800
808
|
}
|
|
809
|
+
set_text(response, body, status) {
|
|
810
|
+
if (status)
|
|
811
|
+
response.status = status;
|
|
812
|
+
response.set('content-type', text_plain);
|
|
813
|
+
response.body = body;
|
|
814
|
+
}
|
|
801
815
|
/** - range: 取值为逗号分割的多个可用端口或端口区间 (不能含有空格,包含区间右值),比如:`8321,8322,8300-8310,11000-11999
|
|
802
816
|
- reverse?: `false` 在 range 内从后往前尝试 */
|
|
803
817
|
static async get_available_port(range, reverse = false) {
|