xshell 1.0.100 → 1.0.102

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/net.js CHANGED
@@ -198,7 +198,7 @@ export async function request(url, options = {}) {
198
198
  headers,
199
199
  body
200
200
  };
201
- if (!((200 <= status && status <= 299) || (redirect === 'manual' && 300 <= status && status < 400)))
201
+ if (!((200 <= status && status <= 299) || status === 304 || (redirect === 'manual' && 300 <= status && status < 400)))
202
202
  throw Object.assign(new Error(t('状态码 {{status}}, 非 2xx: {{url}}', { status: response.status, url })), { name: 'StatusCodeError' });
203
203
  }
204
204
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -469,10 +469,15 @@ export class Server {
469
469
  redirect,
470
470
  timeout
471
471
  });
472
- response.status = response_.status;
473
- response.set(Server.filter_response_headers(response_.headers));
474
- if (response_.body)
475
- response.body = response_.body;
472
+ if (response.writable) {
473
+ response.status = response_.status;
474
+ response.set(Server.filter_response_headers(response_.headers));
475
+ if (response_.body)
476
+ response.body = response_.body;
477
+ }
478
+ else
479
+ // todo: 临时观察
480
+ console.log(`${path_url} 对应的 response.writable === false`);
476
481
  }
477
482
  catch (error) {
478
483
  if (error.response?.status !== 404)
@@ -63,7 +63,7 @@ export declare function encode(str: string): Uint8Array;
63
63
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
64
64
  export declare function decode(buffer: Uint8Array): string;
65
65
  /** 字符串字典序比较 */
66
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
66
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
67
67
  /** 比较 1.10.02 这种版本号 */
68
68
  export declare function vercmp(l: string, r: string): number;
69
69
  export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
package/utils.d.ts CHANGED
@@ -34,12 +34,12 @@ export declare function map_values<TValue, TNewValue>(obj: {
34
34
  };
35
35
  /** 过滤对象中的 keys, 返回新对象 */
36
36
  export declare function filter_keys<TObj>(obj: TObj, filter: (key: string) => any): TObj;
37
- /** 过滤对象中的 keys, 返回新对象 */
37
+ /** 过滤对象中的 valus, 返回新对象 */
38
38
  export declare function filter_values<TObj extends Record<string, any>>(obj: TObj, filter?: (value: TObj[string]) => any): TObj;
39
39
  /** 忽略对象中的 keys, 返回新对象 */
40
40
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
41
41
  /** 字符串字典序比较 */
42
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
42
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
43
43
  /** 比较 1.10.02 这种版本号 */
44
44
  export declare function vercmp(l: string, r: string): number;
45
45
  export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
package/utils.js CHANGED
@@ -80,7 +80,7 @@ export function filter_keys(obj, filter) {
80
80
  return Object.fromEntries(Object.entries(obj)
81
81
  .filter(([key]) => filter(key)));
82
82
  }
83
- /** 过滤对象中的 keys, 返回新对象 */
83
+ /** 过滤对象中的 valus, 返回新对象 */
84
84
  export function filter_values(obj, filter = not_empty) {
85
85
  return Object.fromEntries(Object.entries(obj)
86
86
  .filter(([, value]) => filter(value)));