xshell 1.3.46 → 1.3.48

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/server.d.ts CHANGED
@@ -129,14 +129,19 @@ export declare class Server {
129
129
  - throw_error?: `false` 在遇到 request 请求错误时直接 throw 出来,而不是自动设置到 response */
130
130
  request(ctx: Context, path_url: string | URL, { headers: headers_, redirect, queries, timeout, throw_error, proxy }?: ServerRequestOptions): Promise<true>;
131
131
  static filter_response_headers(headers: RawResponse['headers']): Record<string, string>;
132
- /** 提供静态文件
132
+ /** 提供静态文件,返回是否成功
133
+ - ctx
134
+ - fp: 文件路径
135
+ - 有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,会忽略开头的 /
136
+ - 无 fpd_root 时必须是绝对路径
137
+ - options?
133
138
  @example
134
139
  const prefix_docs = '/zh/'
135
140
  if (path.startsWith(prefix_docs)) {
136
141
  await this.try_send(
137
142
  ctx,
138
143
  (path.endsWith('/') ? `${path}index.html` : path).strip_start(prefix_docs),
139
- { fpd_root: `T:/t/docs${prefix_docs}` },
144
+ { fpd_root: `${fpd_temp}docs${prefix_docs}`, },
140
145
  )
141
146
  return
142
147
  } */
@@ -150,7 +155,9 @@ export declare class Server {
150
155
  /** 将 body 设置为 fp 所指文件的 ReadStream
151
156
  检查 fp 是否合法,设置对应的 content-type,支持缓存,支持分块下载
152
157
  - ctx: Koa.Context
153
- - fp: 文件路径,有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,无 fpd_root 时必须是绝对路径
158
+ - fp: 文件路径
159
+ - 有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,会忽略开头的 /
160
+ - 无 fpd_root 时必须是绝对路径
154
161
  - options?:
155
162
  - fpd_root?: 只能访问 fpd_root 下面的文件
156
163
  - absolute?: `false` 使用绝对路径指定发送的文件
package/server.js CHANGED
@@ -121,6 +121,8 @@ export class Server {
121
121
  app.on('error', this.on_error.bind(this));
122
122
  app.use(this.entry.bind(this));
123
123
  app.use(KoaCompress({
124
+ encodingPreference: ['br', 'zstd', 'gzip', 'identity'],
125
+ threshold: 512,
124
126
  br: {
125
127
  chunkSize: 64 * 1024,
126
128
  // https://nodejs.org/api/zlib.html#zlib_class_brotlioptions
@@ -128,8 +130,7 @@ export class Server {
128
130
  [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
129
131
  [zlib.constants.BROTLI_PARAM_QUALITY]: 3 // 默认为 11 (最大压缩),会导致 news/get 生成的 14 mb 的 json 压缩时长高达 24s
130
132
  },
131
- },
132
- threshold: 512
133
+ }
133
134
  }));
134
135
  app.use(KoaCors({
135
136
  credentials: true,
@@ -640,14 +641,19 @@ export class Server {
640
641
  static filter_response_headers(headers) {
641
642
  return filter_keys(headers, key => !key.startsWith(':') && !this.drop_response_headers.has(key));
642
643
  }
643
- /** 提供静态文件
644
+ /** 提供静态文件,返回是否成功
645
+ - ctx
646
+ - fp: 文件路径
647
+ - 有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,会忽略开头的 /
648
+ - 无 fpd_root 时必须是绝对路径
649
+ - options?
644
650
  @example
645
651
  const prefix_docs = '/zh/'
646
652
  if (path.startsWith(prefix_docs)) {
647
653
  await this.try_send(
648
654
  ctx,
649
655
  (path.endsWith('/') ? `${path}index.html` : path).strip_start(prefix_docs),
650
- { fpd_root: `T:/t/docs${prefix_docs}` },
656
+ { fpd_root: `${fpd_temp}docs${prefix_docs}`, },
651
657
  )
652
658
  return
653
659
  } */
@@ -676,7 +682,9 @@ export class Server {
676
682
  /** 将 body 设置为 fp 所指文件的 ReadStream
677
683
  检查 fp 是否合法,设置对应的 content-type,支持缓存,支持分块下载
678
684
  - ctx: Koa.Context
679
- - fp: 文件路径,有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,无 fpd_root 时必须是绝对路径
685
+ - fp: 文件路径
686
+ - 有 fpd_root 时为相对路径或以 fpd_root 开头的绝对路径,会忽略开头的 /
687
+ - 无 fpd_root 时必须是绝对路径
680
688
  - options?:
681
689
  - fpd_root?: 只能访问 fpd_root 下面的文件
682
690
  - absolute?: `false` 使用绝对路径指定发送的文件