xshell 1.0.26 → 1.0.28

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.browser.js CHANGED
@@ -41,13 +41,13 @@ export async function request(url, { method, queries, headers: _headers, body, t
41
41
  if (_headers instanceof Headers)
42
42
  // @ts-ignore: ts 类型不支持,实际上已经有了
43
43
  for (const [key, value] of _headers)
44
- headers.set(key, value);
44
+ headers.set(key, value); // Headers 类型中不会有也不允许设置 :path 等 : 开头的 key
45
45
  else
46
46
  for (const key in _headers) {
47
47
  const value = _headers[key];
48
48
  if (!value.startsWith(':')) { // 可能在 http/2 的 response 中会有这样开头的保留 headers, 在透传时忽略比较好
49
49
  assert(key === key.toLowerCase(), t('传入 request 的 headers 参数中 key 应该都是小写的,实际为 {{key}}', { key }));
50
- headers[key] = value;
50
+ headers.set(key, value);
51
51
  }
52
52
  }
53
53
  let options = {
package/net.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare enum MyProxy {
17
17
  export declare const cookies: {
18
18
  store: MemoryCookieStore;
19
19
  jar: CookieJar;
20
- get(domain_or_url: string, str?: boolean): Promise<string> | Cookie[] | Promise<Cookie[]>;
20
+ get(domain_or_url: string, str?: boolean): Cookie[] | Promise<string> | Promise<Cookie[]>;
21
21
  };
22
22
  export { Cookie };
23
23
  export interface BasicAuth {
package/net.js CHANGED
@@ -73,20 +73,19 @@ export async function request(url, { method, queries, headers: _headers, body, t
73
73
  if (auth)
74
74
  headers.set('authorization', auth.type === 'basic' ? `Basic ${`${auth.username}:${auth.password}`.to_base64()}` : `Bearer ${auth.token}`);
75
75
  if (_cookies)
76
- Object.entries(_cookies)
76
+ headers.set('cookie', Object.entries(_cookies)
77
77
  .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
78
- .join('; ');
78
+ .join('; '));
79
79
  if (_headers)
80
80
  if (_headers instanceof Headers)
81
- // @ts-ignore: ts 类型不支持,实际上已经有了
82
81
  for (const [key, value] of _headers)
83
- headers.set(key, value);
82
+ headers.set(key, value); // Headers 类型中不会有也不允许设置 :path 等 : 开头的 key
84
83
  else
85
84
  for (const key in _headers) {
86
85
  const value = _headers[key];
87
86
  if (!value.startsWith(':')) { // 可能在 http/2 的 response 中会有这样开头的保留 headers, 在透传时忽略比较好
88
87
  assert(key === key.toLowerCase(), t('传入 request 的 headers 参数中 key 应该都是小写的,实际为 {{key}}', { key }));
89
- headers[key] = value;
88
+ headers.set(key, value);
90
89
  }
91
90
  }
92
91
  let options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {